ZMQContext
class ZMQContext (View source)
Class ZMQContext
Methods
Constructs a new ZMQ context. The context is used to initialize sockets.
(PECL zmq >= 1.0.4) Returns the value of a context option.
(PECL zmq >= 0.5.0) Shortcut for creating new sockets from the context.
(PECL zmq >= 0.5.0) Whether the context is persistent.
(PECL zmq >= 1.0.4) Sets a ZMQ context option. The type of the value depends on the key.
Details
__construct(int $io_threads = 1, bool $is_persistent = true)
Constructs a new ZMQ context. The context is used to initialize sockets.
A persistent context is required to initialize persistent sockets.
string|int
getOpt(string $key)
(PECL zmq >= 1.0.4) Returns the value of a context option.
ZMQSocket
getSocket(int $type, string $persistent_id = null, callable $on_new_socket = null)
(PECL zmq >= 0.5.0) Shortcut for creating new sockets from the context.
If the context is not persistent the persistent_id parameter is ignored and the socket falls back to being non-persistent. The on_new_socket is called only when a new underlying socket structure is created.
bool
isPersistent()
(PECL zmq >= 0.5.0) Whether the context is persistent.
Persistent context is needed for persistent connections as each socket is allocated from a context.
ZMQContext
setOpt(int $key, mixed $value)
(PECL zmq >= 1.0.4) Sets a ZMQ context option. The type of the value depends on the key.
See ZMQ Constant Types for more information.