webserver.php
changeset 62 1b73be5346df
parent 57 31ce64a3ff6c
child 63 af239423ed15
--- 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)