EventHttpConnection::setCloseCallback

(PECL event >= 1.8.0)

EventHttpConnection::setCloseCallbackSet callback for connection close

Description

publicEventHttpConnection::setCloseCallback(callable$callback, mixed$data = ?): void

Sets callback for connection close.

Parameters

callback

Callback which is called when connection is closed. Should match the following prototype:

callback(EventHttpConnection$conn = null, mixed$arg = null): void

Return Values

No value is returned.

Examples

Example #1 EventHttpConnection::setCloseCallback() example

<?php


function _close_callback($conn)
{
echo
__FUNCTION__, PHP_EOL;
}

function
_http_default($req, $dummy)
{
$conn = $req->getConnection();
$conn->setCloseCallback('_close_callback', NULL);


$bev = $req->getBufferEvent();
$bev->enable(Event::READ);
// We have to free it explicitly. See
EventHttpRequest::getConnection()
$bev->free();
To Top