Index: ForkingServer.class.php =================================================================== --- ForkingServer.class.php (revision 7278) +++ ForkingServer.class.php (working copy) @@ -23,6 +23,7 @@ function service() { if (!$this->socket->isConnected()) return FALSE; + $tcp= getprotobyname('tcp'); while (!$this->terminate) { try(); { $m= &$this->socket->accept(); @@ -45,6 +46,7 @@ // Use waitpid w/ NOHANG to avoid zombies hanging around while (pcntl_waitpid(-1, $status, WNOHANG)) { } } else { // Child + $this->tcpnodelay && $m->setOption($tcp, TCP_NODELAY, TRUE); $this->notify(new ConnectionEvent(EVENT_CONNECTED, $m)); // Loop Index: Server.class.php =================================================================== --- Server.class.php (revision 7278) +++ Server.class.php (working copy) @@ -35,7 +35,8 @@ class Server extends Object { var $socket = NULL, - $terminate = FALSE; + $terminate = FALSE, + $tcpnodelay = FALSE; /** * Constructor @@ -82,6 +83,26 @@ $this->listeners[]= &$listener; return $listener; } + + /** + * Set TCP_NODELAY + * + * @access public + * @param bool tcpnodelay + */ + function setTcpnodelay($tcpnodelay) { + $this->tcpnodelay= $tcpnodelay; + } + + /** + * Get TCP_NODELAY + * + * @access public + * @return bool + */ + function getTcpnodelay() { + return $this->tcpnodelay; + } /** * Notify listeners @@ -108,6 +129,7 @@ $accepting= $this->socket->getHandle(); // Loop + $tcp= getprotobyname('tcp'); while (!$this->terminate) { xp::gc(); @@ -142,6 +164,7 @@ return throw(new SocketException('Call to accept() failed')); } + $this->tcpnodelay && $m->setOption($tcp, TCP_NODELAY, TRUE); $this->notify(new ConnectionEvent(EVENT_CONNECTED, $m)); $handles[(int)$m->getHandle()]= &$m; continue; Index: PreforkingServer.class.php =================================================================== --- PreforkingServer.class.php (revision 7278) +++ PreforkingServer.class.php (working copy) @@ -64,6 +64,7 @@ $children= array(); $i= 0; + $tcp= getprotobyname('tcp'); while (!$this->terminate && ($i <= $this->count)) { $this->cat && $this->cat->debugf('Server #%d: Forking child %d', getmypid(), $i); $pid= pcntl_fork(); @@ -83,7 +84,7 @@ exit(-1); } if (!$m) continue; - + $this->tcpnodelay && $m->setOption($tcp, TCP_NODELAY, TRUE); $this->notify(new ConnectionEvent(EVENT_CONNECTED, $m)); // Loop