public function accept($timeout = -1) { if ($timeout !== 0) { $client = stream_socket_accept($this->handle, $timeout); } else { $client = stream_socket_accept($this->handle, $timeout); } if (!\hacklib_cast_as_boolean($client)) { return null; } $socket = new TSocket(); $socket->setHandle($client); $transport = new TBufferedTransport($socket, $this->send_buffer_size, $this->recv_buffer_size); return $transport; }
public function accept($timeout = -1) { if ($timeout !== 0) { $client = stream_socket_accept($this->handle, $timeout); } else { $client = @stream_socket_accept($this->handle, $timeout); } if (!$client) { return false; } $socket = new TSocket(); $socket->setHandle($client); // We need to create a buffered transport because TSocket's isReadable // is not reliable in PHP (hphp is fine) and buffered transport is more // efficient (60% faster in my tests) $transport = new TBufferedTransport($socket, $this->send_buffer_size, $this->recv_buffer_size); return $transport; }
/** * Implementation of accept. If not client is accepted in the given time * * @return TSocket */ protected function acceptImpl() { $handle = @stream_socket_accept($this->listener_, $this->acceptTimeout_ / 1000.0); if (!$handle) { return null; } $socket = new TSocket(); $socket->setHandle($handle); return $socket; }