EventHttp::accept Makes an HTTP server accept connections on the specified socket stream or resource &reftitle.description; public bool EventHttp::accept mixed socket Makes an HTTP server accept connections on the specified socket stream or resource. The socket should be ready to accept connections. Can be called multiple times to accept connections on different sockets. To bind a socket, listen , and accept connections on the socket in s single call use EventHttp::bind . EventHttp::accept is needed only if one already has a socket ready to accept connections. &reftitle.parameters; socket Socket resource, stream or numeric file descriptor representing a socket ready to accept connections. &reftitle.returnvalues; Returns &true; on success. Otherwise &false;. &reftitle.examples; <function>EventHttp::accept</function> example "127.0.0.1", 8092 => "127.0.0.2", ); $i = 0; $socket = array(); foreach ($addresses as $port => $ip) { echo $ip, " ", $port, PHP_EOL; $socket[$i] = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if (!socket_bind($socket[$i], $ip, $port)) { exit("socket_bind failed\n"); } socket_listen($socket[$i], 0); socket_set_nonblock($socket[$i]); if (!$http->accept($socket[$i])) { echo "Accept failed\n"; exit(1); } ++$i; } $http->setCallback("/some-page", function() { echo "(some-page)\n"; echo "URI: ", $req->getUri(), PHP_EOL; $req->sendReply(200, "OK"); echo "OK\n"; }); $http->setDefaultCallback(function($req) { echo "URI: ", $req->getUri(), PHP_EOL; $req->sendReply(200, "OK"); echo "OK\n"; }); $signal = Event::signal($base, SIGINT, function () use ($base) { echo "Caught SIGINT. Stopping...\n"; $base->stop(); }); $signal->add(); $base->dispatch(); echo "END\n"; // We didn't close sockets, since Libevent already sets // CLOSE_ON_FREE and CLOSE_ON_EXEC flags on the file // descriptor associated with the sockets. ?> ]]> &example.outputs.similar; &reftitle.seealso; EventHttp::bind