mirror of
https://github.com/YGGverse/titan-II.git
synced 2025-01-25 22:34:23 +00:00
add ipv6 support
This commit is contained in:
parent
ae72a00361
commit
6be1b4fe2c
@ -115,7 +115,15 @@ class Server {
|
||||
*/
|
||||
protected function openSocket(string $ip, int $port): bool
|
||||
{
|
||||
$addr = "tcp://" . $ip . ':' . $port;
|
||||
if (false !== filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
|
||||
{
|
||||
$addr = 'tcp://[' . $ip . ']:' . $port;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$addr = 'tcp://' . $ip . ':' . $port;
|
||||
}
|
||||
|
||||
$this->socket = stream_socket_server($addr, $errno, $errstr, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $this->context);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user