array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'zmqcontext.construct.php', 1 => 'ZMQContext::__construct', ), 'up' => array ( 0 => 'class.zmqcontext.php', 1 => 'ZMQContext', ), 'prev' => array ( 0 => 'class.zmqcontext.php', 1 => 'ZMQContext', ), 'next' => array ( 0 => 'zmqcontext.getopt.php', 1 => 'ZMQContext::getOpt', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/zmq/zmqcontext/construct.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PECL zmq >= 0.5.0)
ZMQContext::__construct — Construct a new ZMQContext object
Constructs a new ZMQ context. The context is used to initialize sockets. A persistent context is required to initialize persistent sockets.
io_threads
Number of io-threads in the context.
is_persistent
Whether the context is persistent. Persistent context is stored over multiple requests and is a requirement for persistent sockets.
Throws ZMQContextException if context initialization fails.
例1 A ZMQContext() example
Construct a new context and allocate request socket from it
<?php
/* Allocate a new context */
$context = new ZMQContext();
/* Create a new socket */
$socket = $context->getSocket(ZMQ::SOCKET_REQ, 'my sock');
/* Connect the socket */
$socket->connect("tcp://example.com:1234");
/* Send a request */
$socket->send("Hello there");
/* Receive back the response */
$message = $socket->recv();
?>