本文整理汇总了PHP中TSocket::setHandle方法的典型用法代码示例。如果您正苦于以下问题:PHP TSocket::setHandle方法的具体用法?PHP TSocket::setHandle怎么用?PHP TSocket::setHandle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSocket
的用法示例。
在下文中一共展示了TSocket::setHandle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: accept
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;
}
示例2: accept
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;
}
示例3: acceptImpl
/**
* 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;
}