Skip to content

Commit

Permalink
Support listening on IPv6 addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed Apr 20, 2013
1 parent e549b1e commit 04101e2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public function __construct(LoopInterface $loop)

public function listen($port, $host = '127.0.0.1')
{
if (strpos($host, ':') !== false) {
// enclose IPv6 addresses in square brackets before appending port
$host = '[' . $host . ']';
}

$this->master = @stream_socket_server("tcp://$host:$port", $errno, $errstr);
if (false === $this->master) {
$message = "Could not bind to tcp://$host:$port: $errstr";
Expand Down

0 comments on commit 04101e2

Please sign in to comment.