Skip to content

Commit 8284dc1

Browse files
committed
Merge remote-tracking branch 'clue/fix-socket-ipv6'
* clue/fix-socket-ipv6: Support listening on IPv6 addresses
2 parents 1809f27 + bba8afd commit 8284dc1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/React/Socket/Server.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public function __construct(LoopInterface $loop)
1818

1919
public function listen($port, $host = '127.0.0.1')
2020
{
21+
if (strpos($host, ':') !== false) {
22+
// enclose IPv6 addresses in square brackets before appending port
23+
$host = '[' . $host . ']';
24+
}
25+
2126
$this->master = @stream_socket_server("tcp://$host:$port", $errno, $errstr);
2227
if (false === $this->master) {
2328
$message = "Could not bind to tcp://$host:$port: $errstr";

0 commit comments

Comments
 (0)