PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Networking » Net_Server » Bug #2157

socket_shutdown and onShutdown callback

Details

Request #2157socket_shutdown and onShutdown callback
Submitted2004-08-18 13:27 UTC
Fromivan at oxylus dot si
Assignedschst
StatusClosed
PackageNet_Server
PHP Version5.0.0
OSLinux
Roadmaps(Not assigned)

Comments

[2004-08-18 13:27 UTC] ivan at oxylus dot si

Description:
------------
'Fork' driver does not call onShutdown() callback function. Also, socket_shutdown() is not called prior to socket_close() which prevents client from receiving EOF on the socket stream. This, for instance, blocks the fgets() or fread() call on the client.

I propose that we modify the closeConnection() function of the Net/Server/Driver/Fork.php so that it calls socket_shutdown() and also callback onShutdown() prior to exit.

I copy/pasted the function code snippet into "Reproduce code".

Reproduce code:
---------------
function closeConnection()
{
if (!isset($this->clientFD[0])) {
return $this->raiseError( "Connection already has been closed." );
}

if (method_exists($this->callbackObj, "onClose")) {
$this->callbackObj->onClose($id);
}

$this->_sendDebugMessage("Closed connection from ".$this->clientInfo[0]["host"]." on port ".$this->clie$

@socket_shutdown($this->clientFD[0], 2);
@socket_close($this->clientFD[0]);
$this->clientFD[0] = null;
unset($this->clientInfo[0]);

if (method_exists($this->callbackObj, "onShutdown")) {
$this->callbackObj->onShutdown($id);
}
exit;
}