|
|
@ -115,7 +115,15 @@ class Server { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected function openSocket(string $ip, int $port): bool |
|
|
|
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); |
|
|
|
$this->socket = stream_socket_server($addr, $errno, $errstr, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $this->context); |
|
|
|
|
|
|
|
|
|
|
|