# HG changeset patch # User Dan # Date 1229812873 18000 # Node ID 1b73be5346df3e35d90e0566719e2d025b849b53 # Parent 88b105a901bea8a8d3303caaa633736bd459201b Fixed a bug in get_peer_info(); accept() now fully works for multiple bound addresses diff -r 88b105a901be -r 1b73be5346df webserver.php --- a/webserver.php Sun Nov 23 23:55:37 2008 -0500 +++ b/webserver.php Sat Dec 20 17:41:13 2008 -0500 @@ -2075,20 +2075,19 @@ { // the goal of a custom accept() with *_select() is to tick every 200ms to allow signals. foreach ( $this->sock as $sock ) + stream_set_blocking($sock, 1); + $timeout = 200000; + $r = $this->sock; + $selection = @stream_select($r, $w = array($sock), $e = array($sock), 0, $timeout); + if ( !$selection ) { - stream_set_blocking($sock, 1); - $timeout = 200000; - $selection = @stream_select($r = array($sock), $w = array($sock), $e = array($sock), 0, $timeout); - if ( !$selection ) - { - return false; - } - $remote = stream_socket_accept($sock); - $return = new Socket_Stream(); - $return->sock = $remote; - $return->socket_initted = true; - return $return; + return false; } + $remote = stream_socket_accept($r[0]); + $return = new Socket_Stream(); + $return->sock = $remote; + $return->socket_initted = true; + return $return; } function soft_shutdown() @@ -2120,7 +2119,8 @@ function get_peer_info(&$addr, &$port) { $peer = stream_socket_get_name($this->sock, true); - list($addr, $port) = explode(':', $peer); + $addr = substr($peer, 0, strrpos($peer, ':')); + $port = substr($peer, strrpos($peer, ':') + 1); } function write($data)