本文整理汇总了PHP中ZMQSocket::getSockOpt方法的典型用法代码示例。如果您正苦于以下问题:PHP ZMQSocket::getSockOpt方法的具体用法?PHP ZMQSocket::getSockOpt怎么用?PHP ZMQSocket::getSockOpt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZMQSocket
的用法示例。
在下文中一共展示了ZMQSocket::getSockOpt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: recv
/**
* Receive message from socket
* Creates a new message and returns it
* Blocks on recv if socket is not ready for input
*
* @throws Exception if no socket present
* @return Zmsg
*/
public function recv()
{
if (!isset($this->_socket)) {
throw new Exception("No socket supplied");
}
$this->_parts = array();
while (true) {
$this->_parts[] = $this->_socket->recv();
if (!$this->_socket->getSockOpt(ZMQ::SOCKOPT_RCVMORE)) {
break;
}
}
return $this;
}
示例2: handleEvent
/**
* Handle ZMQ Event.
*/
public function handleEvent()
{
while ($this->socket !== null) {
$events = $this->socket->getSockOpt(ZMQ::SOCKOPT_EVENTS);
$hasEvents = $events & ZMQ::POLL_IN || $events & ZMQ::POLL_OUT && $this->buffer->listening;
if (!$hasEvents) {
break;
}
if ($events & ZMQ::POLL_IN) {
$this->handleReadEvent();
}
if ($events & ZMQ::POLL_OUT && $this->buffer->listening) {
$this->buffer->handleWriteEvent();
}
}
}
示例3: indexAction
public function indexAction()
{
$context = new ZMQContext();
$socket = new ZMQSocket($context, ZMQ::SOCKET_DEALER);
//$socket->setSockOpt(ZMQ::SOCKOPT_IDENTITY,"identity");
$socket->getSockOpt(ZMQ::SOCKOPT_IDENTITY);
$socket->connect("tcp://127.0.0.1:5555");
$zmsg = new Zmq_Msg($socket);
$zmsg->body_set("Hello world");
$zmsg->push("echo");
$zmsg->push("MDPC01");
$zmsg->push("");
printf("I: send request to 'echo' service: %s", PHP_EOL);
echo $zmsg->__toString();
$zmsg->send();
return false;
}
示例4: ZMQContext
<?php
/*
* Weather proxy device
* @author Ian Barber <ian(dot)barber(at)gmail(dot)com>
*/
$context = new ZMQContext();
// This is where the weather server sits
$frontend = new ZMQSocket($context, ZMQ::SOCKET_SUB);
$frontend->connect("tcp://192.168.55.210:5556");
// This is our public endpoint for subscribers
$backend = new ZMQSocket($context, ZMQ::SOCKET_PUB);
$backend->bind("tcp://10.1.1.0:8100");
// Subscribe on everything
$frontend->setSockOpt(ZMQ::SOCKOPT_SUBSCRIBE, "");
// Shunt messages out to our own subscribers
while (true) {
while (true) {
// Process all parts of the message
$message = $frontend->recv();
$more = $frontend->getSockOpt(ZMQ::SOCKOPT_RCVMORE);
$backend->send($message, $more ? ZMQ::MODE_SNDMORE : 0);
if (!$more) {
break;
// Last message part
}
}
}
示例5: getTimeout
public function getTimeout()
{
return $this->socket->getSockOpt(\ZMQ::SOCKOPT_RCVTIMEO) / 1000;
}