ZMQSocket
class ZMQSocket (View source)
Class ZMQSocket
Methods
(PECL zmq >= 0.5.0) Constructs a ZMQSocket object.
(PECL zmq >= 0.5.0) Bind the socket to an endpoint.
(PECL zmq >= 0.5.0) Connect the socket to a remote endpoint.
(PECL zmq >= 1.0.4) Disconnect the socket from a previously connected remote endpoint.
Returns a list of endpoints where the socket is connected or bound to.
Returns the persistent id string assigned of the object and NULL if socket is not persistent.
Returns the value of a socket option.
Return the socket type.
Check whether the socket is persistent.
Receive a message from a socket.
Receive an array multipart message from a socket.
Send a message using the socket. The operation can block unless ZMQ::MODE_NOBLOCK is used.
Send a multipart message using the socket. The operation can block unless ZMQ::MODE_NOBLOCK is used.
Sets a ZMQ socket option. The type of the value depends on the key.
Details
__construct(ZMQContext $context, int $type, string $persistent_id = null, callable $on_new_socket = null)
(PECL zmq >= 0.5.0) Constructs a ZMQSocket object.
The persistent_id parameter can be used to allocated a persistent socket. A persistent socket has to be allocated from a persistent context and it stays connected over multiple requests. The persistent_id parameter can be used to recall the same socket over multiple requests. The on_new_socket is called only when a new underlying socket structure is created.
ZMQSocket
bind(string $dsn, bool $force = false)
(PECL zmq >= 0.5.0) Bind the socket to an endpoint.
The endpoint is defined in format transport://address where transport is one of the following: inproc, ipc, tcp, pgm or epgm.
ZMQSocket
connect(string $dsn, bool $force = false)
(PECL zmq >= 0.5.0) Connect the socket to a remote endpoint.
The endpoint is defined in format transport://address where transport is one of the following: inproc, ipc, tcp, pgm or epgm.
ZMQSocket
disconnect(string $dsn)
(PECL zmq >= 1.0.4) Disconnect the socket from a previously connected remote endpoint.
The endpoint is defined in format transport://address where transport is one of the following: inproc, ipc, tcp, pgm or epgm.
array
getEndpoints()
Returns a list of endpoints where the socket is connected or bound to.
string|null
getPersistentId()
Returns the persistent id string assigned of the object and NULL if socket is not persistent.
string|int
getSockOpt(int $key)
Returns the value of a socket option.
This method is available if ZMQ extension has been compiled against ZMQ version 2.0.7 or higher
int
getSocketType()
Return the socket type.
The socket type can be compared against ZMQ::SOCKET_* constants.
bool
isPersistent()
Check whether the socket is persistent.
string|false
recv(int $mode = 0)
Receive a message from a socket.
By default receiving will block until a message is available unless ZMQ::MODE_NOBLOCK flag is used. ZMQ::SOCKOPT_RCVMORE socket option can be used for receiving multi-part messages. Returns the message. If ZMQ::MODE_NOBLOCK is used and the operation would block bool false shall be returned.
string[]
recvMulti(int $mode = 0)
Receive an array multipart message from a socket.
By default receiving will block until a message is available unless ZMQ::MODE_NOBLOCK flag is used. Returns the array of message parts. If ZMQ::MODE_NOBLOCK is used and the operation would block bool false shall be returned.
ZMQSocket
send(string $message, int $mode = 0)
Send a message using the socket. The operation can block unless ZMQ::MODE_NOBLOCK is used.
If ZMQ::MODE_NOBLOCK is used and the operation would block bool false shall be returned.
ZMQSocket
sendmulti(array $message, int $mode = 0)
Send a multipart message using the socket. The operation can block unless ZMQ::MODE_NOBLOCK is used.
If ZMQ::MODE_NOBLOCK is used and the operation would block bool false shall be returned.
ZMQSocket
setSockOpt(int $key, mixed $value)
Sets a ZMQ socket option. The type of the value depends on the key.
ZMQSocket
unbind(string $dsn)
Unbind the socket from an endpoint.
The endpoint is defined in format transport://address where transport is one of the following: inproc, ipc, tcp, pgm or epgm.