From bc5de5074cd8ed67ed919706aa3861b1e4c0a64a Mon Sep 17 00:00:00 2001 From: lacatoire Date: Wed, 5 Aug 2026 10:48:10 +0200 Subject: [PATCH] Add the zmq extension documentation --- reference/zmq/book.xml | 50 ++ reference/zmq/setup.xml | 46 ++ reference/zmq/versions.xml | 117 +++ reference/zmq/zmq.xml | 782 +++++++++++++++++++ reference/zmq/zmq/construct.xml | 54 ++ reference/zmq/zmqcontext.xml | 67 ++ reference/zmq/zmqcontext/construct.xml | 108 +++ reference/zmq/zmqcontext/getopt.xml | 68 ++ reference/zmq/zmqcontext/getsocket.xml | 126 +++ reference/zmq/zmqcontext/ispersistent.xml | 56 ++ reference/zmq/zmqcontext/setopt.xml | 76 ++ reference/zmq/zmqcontextexception.xml | 112 +++ reference/zmq/zmqdevice.xml | 67 ++ reference/zmq/zmqdevice/construct.xml | 87 +++ reference/zmq/zmqdevice/getidletimeout.xml | 54 ++ reference/zmq/zmqdevice/gettimertimeout.xml | 54 ++ reference/zmq/zmqdevice/run.xml | 57 ++ reference/zmq/zmqdevice/setidlecallback.xml | 91 +++ reference/zmq/zmqdevice/setidletimeout.xml | 65 ++ reference/zmq/zmqdevice/settimercallback.xml | 91 +++ reference/zmq/zmqdevice/settimertimeout.xml | 65 ++ reference/zmq/zmqdeviceexception.xml | 112 +++ reference/zmq/zmqexception.xml | 112 +++ reference/zmq/zmqpoll.xml | 67 ++ reference/zmq/zmqpoll/add.xml | 78 ++ reference/zmq/zmqpoll/clear.xml | 55 ++ reference/zmq/zmqpoll/count.xml | 55 ++ reference/zmq/zmqpoll/getlasterrors.xml | 56 ++ reference/zmq/zmqpoll/poll.xml | 172 ++++ reference/zmq/zmqpoll/remove.xml | 68 ++ reference/zmq/zmqpollexception.xml | 112 +++ reference/zmq/zmqsocket.xml | 67 ++ reference/zmq/zmqsocket/bind.xml | 76 ++ reference/zmq/zmqsocket/connect.xml | 122 +++ reference/zmq/zmqsocket/construct.xml | 142 ++++ reference/zmq/zmqsocket/disconnect.xml | 66 ++ reference/zmq/zmqsocket/getendpoints.xml | 54 ++ reference/zmq/zmqsocket/getpersistentid.xml | 55 ++ reference/zmq/zmqsocket/getsockettype.xml | 56 ++ reference/zmq/zmqsocket/getsockopt.xml | 68 ++ reference/zmq/zmqsocket/ispersistent.xml | 55 ++ reference/zmq/zmqsocket/recv.xml | 135 ++++ reference/zmq/zmqsocket/recvmulti.xml | 70 ++ reference/zmq/zmqsocket/send.xml | 76 ++ reference/zmq/zmqsocket/sendmulti.xml | 76 ++ reference/zmq/zmqsocket/setsockopt.xml | 76 ++ reference/zmq/zmqsocket/unbind.xml | 67 ++ reference/zmq/zmqsocketexception.xml | 112 +++ 48 files changed, 4553 insertions(+) create mode 100644 reference/zmq/book.xml create mode 100644 reference/zmq/setup.xml create mode 100644 reference/zmq/versions.xml create mode 100644 reference/zmq/zmq.xml create mode 100644 reference/zmq/zmq/construct.xml create mode 100644 reference/zmq/zmqcontext.xml create mode 100644 reference/zmq/zmqcontext/construct.xml create mode 100644 reference/zmq/zmqcontext/getopt.xml create mode 100644 reference/zmq/zmqcontext/getsocket.xml create mode 100644 reference/zmq/zmqcontext/ispersistent.xml create mode 100644 reference/zmq/zmqcontext/setopt.xml create mode 100644 reference/zmq/zmqcontextexception.xml create mode 100644 reference/zmq/zmqdevice.xml create mode 100644 reference/zmq/zmqdevice/construct.xml create mode 100644 reference/zmq/zmqdevice/getidletimeout.xml create mode 100644 reference/zmq/zmqdevice/gettimertimeout.xml create mode 100644 reference/zmq/zmqdevice/run.xml create mode 100644 reference/zmq/zmqdevice/setidlecallback.xml create mode 100644 reference/zmq/zmqdevice/setidletimeout.xml create mode 100644 reference/zmq/zmqdevice/settimercallback.xml create mode 100644 reference/zmq/zmqdevice/settimertimeout.xml create mode 100644 reference/zmq/zmqdeviceexception.xml create mode 100644 reference/zmq/zmqexception.xml create mode 100644 reference/zmq/zmqpoll.xml create mode 100644 reference/zmq/zmqpoll/add.xml create mode 100644 reference/zmq/zmqpoll/clear.xml create mode 100644 reference/zmq/zmqpoll/count.xml create mode 100644 reference/zmq/zmqpoll/getlasterrors.xml create mode 100644 reference/zmq/zmqpoll/poll.xml create mode 100644 reference/zmq/zmqpoll/remove.xml create mode 100644 reference/zmq/zmqpollexception.xml create mode 100644 reference/zmq/zmqsocket.xml create mode 100644 reference/zmq/zmqsocket/bind.xml create mode 100644 reference/zmq/zmqsocket/connect.xml create mode 100644 reference/zmq/zmqsocket/construct.xml create mode 100644 reference/zmq/zmqsocket/disconnect.xml create mode 100644 reference/zmq/zmqsocket/getendpoints.xml create mode 100644 reference/zmq/zmqsocket/getpersistentid.xml create mode 100644 reference/zmq/zmqsocket/getsockettype.xml create mode 100644 reference/zmq/zmqsocket/getsockopt.xml create mode 100644 reference/zmq/zmqsocket/ispersistent.xml create mode 100644 reference/zmq/zmqsocket/recv.xml create mode 100644 reference/zmq/zmqsocket/recvmulti.xml create mode 100644 reference/zmq/zmqsocket/send.xml create mode 100644 reference/zmq/zmqsocket/sendmulti.xml create mode 100644 reference/zmq/zmqsocket/setsockopt.xml create mode 100644 reference/zmq/zmqsocket/unbind.xml create mode 100644 reference/zmq/zmqsocketexception.xml diff --git a/reference/zmq/book.xml b/reference/zmq/book.xml new file mode 100644 index 0000000..e9474c2 --- /dev/null +++ b/reference/zmq/book.xml @@ -0,0 +1,50 @@ + + + + + + + ZMQ + 0MQ messaging + + + &reftitle.intro; + + &warn.experimental; + "ØMQ is a software library that lets you quickly design and implement a fast message-based application." --0MQ Website + + + For more information about 0MQ, see &url.zeromq;. + + + + &reference.zmq.setup; + + &reference.zmq.zmq; + &reference.zmq.zmqcontext; + &reference.zmq.zmqsocket; + &reference.zmq.zmqpoll; + &reference.zmq.zmqdevice; + + + + diff --git a/reference/zmq/setup.xml b/reference/zmq/setup.xml new file mode 100644 index 0000000..fca5c22 --- /dev/null +++ b/reference/zmq/setup.xml @@ -0,0 +1,46 @@ + + + + + &reftitle.setup; + +
+ &reftitle.required; + + ZMQ extension requires 0MQ version 2.0.7 or higher. 0MQ can be acquired from &url.zeromq;area:download. + +
+ +
+ &reftitle.install; + + + &pecl.info.dead; + &url.pecl.package;zmq + + + &pecl.windows.download.avail; + +
+
+ + diff --git a/reference/zmq/versions.xml b/reference/zmq/versions.xml new file mode 100644 index 0000000..878a019 --- /dev/null +++ b/reference/zmq/versions.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/reference/zmq/zmq.xml b/reference/zmq/zmq.xml new file mode 100644 index 0000000..f4cc748 --- /dev/null +++ b/reference/zmq/zmq.xml @@ -0,0 +1,782 @@ + + + + + + The ZMQ class + ZMQ + + + + +
+ &reftitle.intro; + + + +
+ + +
+ &reftitle.classsynopsis; + + + + ZMQ + + + + + ZMQ + + + + &Constants; + + const + int + ZMQ::SOCKET_PAIR + + + const + int + ZMQ::SOCKET_PUB + + + const + int + ZMQ::SOCKET_SUB + + + const + int + ZMQ::SOCKET_REQ + + + const + int + ZMQ::SOCKET_REP + + + const + int + ZMQ::SOCKET_XREQ + + + const + int + ZMQ::SOCKET_XREP + + + const + int + ZMQ::SOCKET_PUSH + + + const + int + ZMQ::SOCKET_PULL + + + const + int + ZMQ::SOCKET_ROUTER + + + const + int + ZMQ::SOCKET_DEALER + + + const + int + ZMQ::SOCKET_XPUB + + + const + int + ZMQ::SOCKET_XSUB + + + const + int + ZMQ::SOCKET_STREAM + + + const + int + ZMQ::SOCKOPT_HWM + + + const + int + ZMQ::SOCKOPT_SNDHWM + + + const + int + ZMQ::SOCKOPT_RCVHWM + + + const + int + ZMQ::SOCKOPT_AFFINITY + + + const + int + ZMQ::SOCKOPT_IDENTITY + + + const + int + ZMQ::SOCKOPT_SUBSCRIBE + + + const + int + ZMQ::SOCKOPT_UNSUBSCRIBE + + + const + int + ZMQ::SOCKOPT_RATE + + + const + int + ZMQ::SOCKOPT_RECOVERY_IVL + + + const + int + ZMQ::SOCKOPT_RECONNECT_IVL + + + const + int + ZMQ::SOCKOPT_RECONNECT_IVL_MAX + + + const + int + ZMQ::SOCKOPT_MCAST_LOOP + + + const + int + ZMQ::SOCKOPT_SNDBUF + + + const + int + ZMQ::SOCKOPT_RCVBUF + + + const + int + ZMQ::SOCKOPT_RCVMORE + + + const + int + ZMQ::SOCKOPT_TYPE + + + const + int + ZMQ::SOCKOPT_LINGER + + + const + int + ZMQ::SOCKOPT_BACKLOG + + + const + int + ZMQ::SOCKOPT_MAXMSGSIZE + + + const + int + ZMQ::SOCKOPT_SNDTIMEO + + + const + int + ZMQ::SOCKOPT_RCVTIMEO + + + const + int + ZMQ::SOCKOPT_IPV4ONLY + + + const + int + ZMQ::SOCKOPT_LAST_ENDPOINT + + + const + int + ZMQ::SOCKOPT_TCP_KEEPALIVE_IDLE + + + const + int + ZMQ::SOCKOPT_TCP_KEEPALIVE_CNT + + + const + int + ZMQ::SOCKOPT_TCP_KEEPALIVE_INTVL + + + const + int + ZMQ::SOCKOPT_TCP_ACCEPT_FILTER + + + const + int + ZMQ::SOCKOPT_TCP_ACCEPT_FILTER + + + const + int + ZMQ::SOCKOPT_DELAY_ATTACH_ON_CONNECT + + + const + int + ZMQ::SOCKOPT_XPUB_VERBOSE + + + const + int + ZMQ::SOCKOPT_ROUTER_RAW + + + const + int + ZMQ::SOCKOPT_IPV6 + + + const + int + ZMQ::CTXOPT_MAX_SOCKETS + + + const + int + ZMQ::POLL_IN + + + const + int + ZMQ::POLL_OUT + + + const + int + ZMQ::MODE_NOBLOCK + + + const + int + ZMQ::MODE_DONTWAIT + + + const + int + ZMQ::MODE_SNDMORE + + + const + int + ZMQ::ERR_INTERNAL + + + const + int + ZMQ::ERR_EAGAIN + + + const + int + ZMQ::ERR_ENOTSUP + + + const + int + ZMQ::ERR_EFSM + + + const + int + ZMQ::ERR_ETERM + + + &Methods; + + + + +
+ + +
+ &reftitle.constants; +
+ ZMQ Constant Types + + + + ZMQ::SOCKET_PAIR + + Exclusive pair pattern + + + + + ZMQ::SOCKET_PUB + + Publisher socket + + + + + ZMQ::SOCKET_SUB + + Subscriber socket + + + + + ZMQ::SOCKET_REQ + + Request socket + + + + + ZMQ::SOCKET_REP + + Reply socket + + + + + ZMQ::SOCKET_XREQ + + Alias for SOCKET_DEALER + + + + + ZMQ::SOCKET_XREP + + Alias for SOCKET_ROUTER + + + + + ZMQ::SOCKET_PUSH + + Pipeline upstream push socket + + + + + ZMQ::SOCKET_PULL + + Pipeline downstream pull socket + + + + + ZMQ::SOCKET_ROUTER + + Extended REP socket that can route replies to requesters + + + + + ZMQ::SOCKET_DEALER + + Extended REQ socket that load balances to all connected peers + + + + + ZMQ::SOCKET_XPUB + + Similar to SOCKET_PUB, except you can receive subscriptions as messages. + The subscription message is 0 (unsubscribe) or 1 (subscribe) followed by the topic. + + + + + ZMQ::SOCKET_XSUB + + Similar to SOCKET_SUB, except you can send subscriptions as messages. See SOCKET_XPUB for format. + + + + + ZMQ::SOCKET_STREAM + + Used to send and receive TCP data from a non-ØMQ peer. Available if compiled against ZeroMQ 4.x or higher (Value: &integer;). + + + + + ZMQ::SOCKOPT_HWM + + The high water mark for inbound and outbound messages is a hard limit on the maximum number of outstanding messages ØMQ shall queue in memory for any single peer that the specified socket is communicating with. Setting this option on a socket will only affect connections made after the option has been set. On ZeroMQ 3.x this is a wrapper for setting both SNDHWM and RCVHWM. (Value: &integer;). + + + + + ZMQ::SOCKOPT_SNDHWM + + The ZMQ_SNDHWM option shall set the high water mark for outbound messages on the specified socket. Available if compiled against ZeroMQ 3.x or higher (Value: &integer;). + + + + + ZMQ::SOCKOPT_RCVHWM + + The SOCKOPT_RCVHWM option shall set the high water mark for inbound messages on the specified socket. Available if compiled against ZeroMQ 3.x or higher (Value: &integer;). + + + + + ZMQ::SOCKOPT_AFFINITY + + Set I/O thread affinity (Value: &integer;) + + + + + ZMQ::SOCKOPT_IDENTITY + + Set socket identity (Value: &string;) + + + + + ZMQ::SOCKOPT_SUBSCRIBE + + Establish message filter. Valid for subscriber socket (Value: &string;) + + + + + ZMQ::SOCKOPT_UNSUBSCRIBE + + Remove message filter. Valid for subscriber socket (Value: &string;) + + + + + ZMQ::SOCKOPT_RATE + + Set rate for multicast sockets (pgm) (Value: &integer; >= 0) + + + + + ZMQ::SOCKOPT_RECOVERY_IVL + + Set multicast recovery interval (Value: &integer; >= 0) + + + + + ZMQ::SOCKOPT_RECONNECT_IVL + + Set the initial reconnection interval (Value: &integer; >= 0) + + + + + ZMQ::SOCKOPT_RECONNECT_IVL_MAX + + Set the max reconnection interval (Value: &integer; >= 0) + + + + + ZMQ::SOCKOPT_MCAST_LOOP + + Control multicast loopback (Value: &integer; >= 0) + + + + + ZMQ::SOCKOPT_SNDBUF + + Set kernel transmit buffer size (Value: &integer; >= 0) + + + + + ZMQ::SOCKOPT_RCVBUF + + Set kernel receive buffer size (Value: &integer; >= 0) + + + + + ZMQ::SOCKOPT_RCVMORE + + Receive multi-part messages (Value: &integer;) + + + + + ZMQ::SOCKOPT_TYPE + + Get the socket type. Valid for getSockOpt (Value: &integer;) + + + + + ZMQ::SOCKOPT_LINGER + + The linger value of the socket. Specifies how long the socket blocks + trying flush messages after it has been closed (Value: &integer;) + + + + + ZMQ::SOCKOPT_BACKLOG + + The SOCKOPT_BACKLOG option shall set the maximum length of the queue of outstanding peer connections for the specified socket; this only applies to connection-oriented transports. (Value: &integer;) + + + + + ZMQ::SOCKOPT_MAXMSGSIZE + + Limits the maximum size of the inbound message. Value -1 means no limit. Available if compiled against ZeroMQ 3.x or higher (Value: &integer;) + + + + + ZMQ::SOCKOPT_SNDTIMEO + + Sets the timeout for send operation on the socket. Value -1 means no limit. Available if compiled against ZeroMQ 3.x or higher (Value: &integer;) + + + + + ZMQ::SOCKOPT_RCVTIMEO + + Sets the timeout for receive operation on the socket. Value -1 means no limit. Available if compiled against ZeroMQ 3.x or higher (Value: &integer;) + + + + + ZMQ::SOCKOPT_IPV4ONLY + + Disable IPV6 support if 1. Available if compiled against ZeroMQ 3.x (Value: &integer;) + + + + + ZMQ::SOCKOPT_LAST_ENDPOINT + + Retrieve the last connected endpoint - for use with * wildcard ports. Available if compiled against ZeroMQ 3.x or higher (Value: &string;) + + + + + ZMQ::SOCKOPT_TCP_KEEPALIVE_IDLE + + Idle time for TCP keepalive. Available if compiled against ZeroMQ 3.x or higher (Value: &integer;) + + + + + ZMQ::SOCKOPT_TCP_KEEPALIVE_CNT + + Count time for TCP keepalive. Available if compiled against ZeroMQ 3.x or higher (Value: &integer;) + + + + + ZMQ::SOCKOPT_TCP_KEEPALIVE_INTVL + + Interval for TCP keepalive. Available if compiled against ZeroMQ 3.x or higher (Value: &integer;) + + + + + ZMQ::SOCKOPT_DELAY_ATTACH_ON_CONNECT + + Set a CIDR string to match against incoming TCP connections. Available if compiled against ZeroMQ 3.x or higher (Value: &string;) + + + + + ZMQ::SOCKOPT_TCP_ACCEPT_FILTER + + Set a CIDR string to match against incoming TCP connections. Available if compiled against ZeroMQ 3.x or higher (Value: &string;) + + + + + ZMQ::SOCKOPT_XPUB_VERBOSE + + Set the XPUB to receive an application message on each instance of a subscription. Available if compiled against ZeroMQ 3.x or higher (Value: &string;) + + + + + ZMQ::SOCKOPT_ROUTER_RAW + + Sets the raw mode on the ROUTER, when set to 1. In raw mode when using tcp:// transport the socket will read and write without ZeroMQ framing. + Available if compiled against ZeroMQ 4.0 or higher (Value: &string;) + + + + + ZMQ::SOCKOPT_IPV6 + + Enable IPV6. Available if compiled against ZeroMQ 4.0 or higher (Value: &string;) + + + + + ZMQ::CTXOPT_MAX_SOCKETS + + The socket limit for this context. Available if compiled against ZeroMQ 3.x or higher (Value: &integer;) + + + + + ZMQ::POLL_IN + + Poll for incoming data + + + + + ZMQ::POLL_OUT + + Poll for outgoing data + + + + + ZMQ::MODE_NOBLOCK + + Non-blocking operation. Deprecated, use ZMQ::MODE_DONTWAIT instead + + + + + ZMQ::MODE_DONTWAIT + + Non-blocking operation + + + + + ZMQ::MODE_SNDMORE + + Send multi-part message + + + + + ZMQ::DEVICE_FORWARDER + + Forwarder device + + + + + ZMQ::DEVICE_QUEUE + + Queue device + + + + + ZMQ::DEVICE_STREAMER + + Streamer device + + + + + ZMQ::ERR_INTERNAL + + ZMQ extension internal error + + + + + ZMQ::ERR_EAGAIN + + Implies that the operation would block when ZMQ::MODE_DONTWAIT is used + + + + + ZMQ::ERR_ENOTSUP + + The operation is not supported by the socket type + + + + + ZMQ::ERR_EFSM + + The operation can not be executed because the socket is not in correct state + + + + + ZMQ::ERR_ETERM + + The context has been terminated + + + + +
+
+ + + +
+ + &reference.zmq.entities.zmq; + +
+ + diff --git a/reference/zmq/zmq/construct.xml b/reference/zmq/zmq/construct.xml new file mode 100644 index 0000000..b1e0db4 --- /dev/null +++ b/reference/zmq/zmq/construct.xml @@ -0,0 +1,54 @@ + + + + + + ZMQ::__construct + ZMQ constructor + + + + &reftitle.description; + + private ZMQ::__construct + + + + Private constructor to prevent direct initialization. This class holds the constants for ZMQ extension. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + + + + + + + diff --git a/reference/zmq/zmqcontext.xml b/reference/zmq/zmqcontext.xml new file mode 100644 index 0000000..708619f --- /dev/null +++ b/reference/zmq/zmqcontext.xml @@ -0,0 +1,67 @@ + + + + + + The ZMQContext class + ZMQContext + + + + +
+ &reftitle.intro; + + + +
+ + +
+ &reftitle.classsynopsis; + + + + ZMQContext + + + + + ZMQContext + + + + + &Methods; + + + + +
+ +
+ + &reference.zmq.entities.zmqcontext; + +
+ + diff --git a/reference/zmq/zmqcontext/construct.xml b/reference/zmq/zmqcontext/construct.xml new file mode 100644 index 0000000..1fe6719 --- /dev/null +++ b/reference/zmq/zmqcontext/construct.xml @@ -0,0 +1,108 @@ + + + + + + ZMQContext::__construct + Construct a new ZMQContext object + + + + &reftitle.description; + + public ZMQContext::__construct + intio_threads1 + boolis_persistent&true; + + + Constructs a new ZMQ context. The context is used to initialize sockets. A persistent context is required + to initialize persistent sockets. + + + + + &reftitle.parameters; + + + + 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. + + + + + + + + + &reftitle.errors; + + Throws ZMQContextException if context initialization fails. + + + + + &reftitle.examples; + + + A <function>ZMQContext</function> example + + Construct a new context and allocate request socket from it + + +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(); +?> +]]> + + + + + + + + diff --git a/reference/zmq/zmqcontext/getopt.xml b/reference/zmq/zmqcontext/getopt.xml new file mode 100644 index 0000000..1b53bfd --- /dev/null +++ b/reference/zmq/zmqcontext/getopt.xml @@ -0,0 +1,68 @@ + + + + + + ZMQContext::getOpt + Get context option + + + + &reftitle.description; + + public mixedZMQContext::getOpt + stringkey + + + Returns the value of a context option. + + + + + &reftitle.parameters; + + + + key + + + An integer representing the option. + See the ZMQ::CTXOPT_* constants. + + + + + + + + + &reftitle.returnvalues; + + Returns either a &string; or an &integer; depending on key. Throws + ZMQContextException on error. + + + + + + + diff --git a/reference/zmq/zmqcontext/getsocket.xml b/reference/zmq/zmqcontext/getsocket.xml new file mode 100644 index 0000000..1aa6e0d --- /dev/null +++ b/reference/zmq/zmqcontext/getsocket.xml @@ -0,0 +1,126 @@ + + + + + + ZMQContext::getSocket + Create a new socket + + + + &reftitle.description; + + public ZMQSocketZMQContext::getSocket + inttype + stringpersistent_id&null; + callableon_new_socket&null; + + + 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. + + + + + &reftitle.parameters; + + + + type + + + ZMQ::SOCKET_* constant to specify socket type. + + + + + persistent_id + + + If persistent_id is specified the socket will be persisted over multiple requests. + + + + + on_new_socket + + + Callback function, which is executed when a new socket structure is created. This function does not get invoked + if the underlying persistent connection is re-used. The callback takes ZMQSocket and persistent_id as two arguments. + + + + + + + + + &reftitle.returnvalues; + + Returns a ZMQSocket object. + + + + + &reftitle.errors; + + Throws ZMQSocketException on error. + + + + + &reftitle.examples; + + + A <function>ZMQContext</function> example + + Basic usage + + +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(); +echo "Received message: {$message}\n"; +?> +]]> + + + + + + + + diff --git a/reference/zmq/zmqcontext/ispersistent.xml b/reference/zmq/zmqcontext/ispersistent.xml new file mode 100644 index 0000000..60d3d43 --- /dev/null +++ b/reference/zmq/zmqcontext/ispersistent.xml @@ -0,0 +1,56 @@ + + + + + + ZMQContext::isPersistent + Whether the context is persistent + + + + &reftitle.description; + + public boolZMQContext::isPersistent + + + + Whether the context is persistent. Persistent context is needed for persistent connections as each + socket is allocated from a context. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + Returns &true; if the context is persistent and &false; if the context is non-persistent. + + + + + + + diff --git a/reference/zmq/zmqcontext/setopt.xml b/reference/zmq/zmqcontext/setopt.xml new file mode 100644 index 0000000..15a42cc --- /dev/null +++ b/reference/zmq/zmqcontext/setopt.xml @@ -0,0 +1,76 @@ + + + + + + ZMQContext::setOpt + Set a socket option + + + + &reftitle.description; + + public ZMQContextZMQContext::setOpt + intkey + mixedvalue + + + Sets a ZMQ context option. The type of the value depends on the key. + See ZMQ Constant Types for more information. + + + + + &reftitle.parameters; + + + + key + + + One of the ZMQ::CTXOPT_* constants. + + + + + value + + + The value of the parameter. + + + + + + + + + &reftitle.returnvalues; + + Returns the current object. Throws ZMQContextException on error. + + + + + + + diff --git a/reference/zmq/zmqcontextexception.xml b/reference/zmq/zmqcontextexception.xml new file mode 100644 index 0000000..3fb698a --- /dev/null +++ b/reference/zmq/zmqcontextexception.xml @@ -0,0 +1,112 @@ + + + + + + The ZMQContextException class + ZMQContextException + + + + +
+ &reftitle.intro; + + + +
+ + +
+ &reftitle.classsynopsis; + + + + ZMQContextException + + + + + ZMQContextException + + + + extends + ZMQException + + + + &Properties; + + + &Methods; + + + &InheritedMethods; + + + + + +
+ + + +
+ &reftitle.properties; + + + message + + + + + + code + + + + + + file + + + + + + line + + + + + +
+ + + +
+ + &reference.zmq.entities.zmqcontextexception; + +
+ + diff --git a/reference/zmq/zmqdevice.xml b/reference/zmq/zmqdevice.xml new file mode 100644 index 0000000..0f3c0da --- /dev/null +++ b/reference/zmq/zmqdevice.xml @@ -0,0 +1,67 @@ + + + + + + The ZMQDevice class + ZMQDevice + + + + +
+ &reftitle.intro; + + + +
+ + +
+ &reftitle.classsynopsis; + + + + ZMQDevice + + + + + ZMQDevice + + + + + &Methods; + + + + +
+ +
+ + &reference.zmq.entities.zmqdevice; + +
+ + diff --git a/reference/zmq/zmqdevice/construct.xml b/reference/zmq/zmqdevice/construct.xml new file mode 100644 index 0000000..98d6c04 --- /dev/null +++ b/reference/zmq/zmqdevice/construct.xml @@ -0,0 +1,87 @@ + + + + + + ZMQDevice::__construct + Construct a new device + + + + &reftitle.description; + + public ZMQDevice::__construct + ZMQSocketfrontend + ZMQSocketbackend + ZMQSocketlistener + + + "ØMQ devices can do intermediation of addresses, services, queues, or any other abstraction you care to define above the message and socket layers." -- zguide + + + + + &reftitle.parameters; + + + frontend + + + Frontend parameter for the devices. Usually where there messages + are coming. + + + + + backend + + + Backend parameter for the devices. Usually where there messages + going to. + + + + + listener + + + Listener socket, which receives a copy of all messages going both directions. + The type of this socket should be SUB, PULL or DEALER. + + + + + + + + &reftitle.returnvalues; + + Call to this method will prepare the device. Usually devices are very long + running processes so running this method from interactive script is not recommended. This + method throw ZMQDeviceException if the device cannot be started. + + + + + + + diff --git a/reference/zmq/zmqdevice/getidletimeout.xml b/reference/zmq/zmqdevice/getidletimeout.xml new file mode 100644 index 0000000..90d70b0 --- /dev/null +++ b/reference/zmq/zmqdevice/getidletimeout.xml @@ -0,0 +1,54 @@ + + + + + + ZMQDevice::getIdleTimeout + Get the idle timeout + + + + &reftitle.description; + + public ZMQDeviceZMQDevice::getIdleTimeout + + + + Gets the idle callback timeout value. Added in ZMQ extension version 1.1.0. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + This method returns the idle callback timeout value. + + + + + + diff --git a/reference/zmq/zmqdevice/gettimertimeout.xml b/reference/zmq/zmqdevice/gettimertimeout.xml new file mode 100644 index 0000000..535b197 --- /dev/null +++ b/reference/zmq/zmqdevice/gettimertimeout.xml @@ -0,0 +1,54 @@ + + + + + + ZMQDevice::getTimerTimeout + Get the timer timeout + + + + &reftitle.description; + + public ZMQDeviceZMQDevice::getTimerTimeout + + + + Gets the timer callback timeout value. Added in ZMQ extension version 1.1.0. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + This method returns the timer timeout value. + + + + + + diff --git a/reference/zmq/zmqdevice/run.xml b/reference/zmq/zmqdevice/run.xml new file mode 100644 index 0000000..06ff8c2 --- /dev/null +++ b/reference/zmq/zmqdevice/run.xml @@ -0,0 +1,57 @@ + + + + + + ZMQDevice::run + Run the new device + + + + &reftitle.description; + + public voidZMQDevice::run + + + + Runs the device. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + Call to this method will block until the device is running. It is not recommended + that devices are used from interactive scripts. On failure this method will throw + ZMQDeviceException. + + + + + + + diff --git a/reference/zmq/zmqdevice/setidlecallback.xml b/reference/zmq/zmqdevice/setidlecallback.xml new file mode 100644 index 0000000..0ea5342 --- /dev/null +++ b/reference/zmq/zmqdevice/setidlecallback.xml @@ -0,0 +1,91 @@ + + + + + + ZMQDevice::setIdleCallback + Set the idle callback function + + + + &reftitle.description; + + public ZMQDeviceZMQDevice::setIdleCallback + callablecb_func + inttimeout + mixeduser_data + + + Sets the idle callback function. If idle timeout is defined the idle callback function + shall be called if the internal poll loop times out without events. If the callback function + returns false or a value that evaluates to false the device is stopped. + + The callback function signature is callback (mixed $user_data). + + + + + &reftitle.parameters; + + + cb_func + + + Callback function to invoke when the device is idle. Returning false + or a value that evaluates to false from this function will cause the + device to stop. + + + + + timeout + + + How often to invoke the idle callback in milliseconds. The idle callback is invoked + periodically when there is no activity on the device. + The timeout value guarantees that there is at least this amount of milliseconds between + invocations of the callback function. + + + + + user_data + + + Additional data to pass to the callback function. + + + + + + + + &reftitle.returnvalues; + + On success this method returns the current object. + + + + + + + diff --git a/reference/zmq/zmqdevice/setidletimeout.xml b/reference/zmq/zmqdevice/setidletimeout.xml new file mode 100644 index 0000000..2f04633 --- /dev/null +++ b/reference/zmq/zmqdevice/setidletimeout.xml @@ -0,0 +1,65 @@ + + + + + + ZMQDevice::setIdleTimeout + Set the idle timeout + + + + &reftitle.description; + + public ZMQDeviceZMQDevice::setIdleTimeout + inttimeout + + + Sets the idle callback timeout value. The idle callback is invoked periodically when the device is + idle. + + + + + &reftitle.parameters; + + + timeout + + + The idle callback timeout value. + + + + + + + + &reftitle.returnvalues; + + On success this method returns the current object. + + + + + + + diff --git a/reference/zmq/zmqdevice/settimercallback.xml b/reference/zmq/zmqdevice/settimercallback.xml new file mode 100644 index 0000000..ee71791 --- /dev/null +++ b/reference/zmq/zmqdevice/settimercallback.xml @@ -0,0 +1,91 @@ + + + + + + ZMQDevice::setTimerCallback + Set the timer callback function + + + + &reftitle.description; + + public ZMQDeviceZMQDevice::setTimerCallback + callablecb_func + inttimeout + mixeduser_data + + + Sets the timer callback function. The timer callback will be invoked after timeout has + passed. The difference between idle and timer callbacks are that idle callback is invoked + only when the device is idle. + + The callback function signature is callback (mixed $user_data). Added in ZMQ extension version 1.1.0. + + + + + &reftitle.parameters; + + + cb_func + + + Callback function to invoke when the timer fires. Returning false + or a value that evaluates to false from this function will cause the + device to stop. + + + + + timeout + + + How often to invoke the timer callback in milliseconds. The timer callback is invoked + periodically. + The timeout value guarantees that there is at least this amount of milliseconds between + invocations of the callback function. + + + + + user_data + + + Additional data to pass to the callback function. + + + + + + + + &reftitle.returnvalues; + + On success this method returns the current object. + + + + + + + diff --git a/reference/zmq/zmqdevice/settimertimeout.xml b/reference/zmq/zmqdevice/settimertimeout.xml new file mode 100644 index 0000000..269d0e8 --- /dev/null +++ b/reference/zmq/zmqdevice/settimertimeout.xml @@ -0,0 +1,65 @@ + + + + + + ZMQDevice::setTimerTimeout + Set the timer timeout + + + + &reftitle.description; + + public ZMQDeviceZMQDevice::setTimerTimeout + inttimeout + + + Sets the timer callback timeout value. The timer callback is invoked periodically if it's set. + Added in ZMQ extension version 1.1.0. + + + + + &reftitle.parameters; + + + timeout + + + The timer callback timeout value. + + + + + + + + &reftitle.returnvalues; + + On success this method returns the current object. + + + + + + + diff --git a/reference/zmq/zmqdeviceexception.xml b/reference/zmq/zmqdeviceexception.xml new file mode 100644 index 0000000..d97b825 --- /dev/null +++ b/reference/zmq/zmqdeviceexception.xml @@ -0,0 +1,112 @@ + + + + + + The ZMQDeviceException class + ZMQDeviceException + + + + +
+ &reftitle.intro; + + + +
+ + +
+ &reftitle.classsynopsis; + + + + ZMQDeviceException + + + + + ZMQDeviceException + + + + extends + ZMQException + + + + &Properties; + + + &Methods; + + + &InheritedMethods; + + + + + +
+ + + +
+ &reftitle.properties; + + + message + + + + + + code + + + + + + file + + + + + + line + + + + + +
+ + + +
+ + &reference.zmq.entities.zmqdeviceexception; + +
+ + diff --git a/reference/zmq/zmqexception.xml b/reference/zmq/zmqexception.xml new file mode 100644 index 0000000..5977e35 --- /dev/null +++ b/reference/zmq/zmqexception.xml @@ -0,0 +1,112 @@ + + + + + + The ZMQException class + ZMQException + + + + +
+ &reftitle.intro; + + + +
+ + +
+ &reftitle.classsynopsis; + + + + ZMQException + + + + + ZMQException + + + + extends + Exception + + + + &Properties; + + + &Methods; + + + &InheritedMethods; + + + + + +
+ + + +
+ &reftitle.properties; + + + message + + + + + + code + + + + + + file + + + + + + line + + + + + +
+ + + +
+ + &reference.zmq.entities.zmqexception; + +
+ + diff --git a/reference/zmq/zmqpoll.xml b/reference/zmq/zmqpoll.xml new file mode 100644 index 0000000..512c0e4 --- /dev/null +++ b/reference/zmq/zmqpoll.xml @@ -0,0 +1,67 @@ + + + + + + The ZMQPoll class + ZMQPoll + + + + +
+ &reftitle.intro; + + + +
+ + +
+ &reftitle.classsynopsis; + + + + ZMQPoll + + + + + ZMQPoll + + + + + &Methods; + + + + +
+ +
+ + &reference.zmq.entities.zmqpoll; + +
+ + diff --git a/reference/zmq/zmqpoll/add.xml b/reference/zmq/zmqpoll/add.xml new file mode 100644 index 0000000..d75662f --- /dev/null +++ b/reference/zmq/zmqpoll/add.xml @@ -0,0 +1,78 @@ + + + + + + ZMQPoll::add + Add item to the poll set + + + + &reftitle.description; + + public stringZMQPoll::add + mixedentry + inttype + + + Adds a new item to the poll set and returns the internal id of the added item. The item can be removed + from the poll set using the returned string id. + + + + + &reftitle.parameters; + + + + entry + + + ZMQSocket object or a PHP stream resource + + + + + type + + + Defines what activity the socket is polled for. + See ZMQ::POLL_IN and ZMQ::POLL_OUT constants. + + + + + + + + + &reftitle.returnvalues; + + Returns a string id of the added item which can be later used to remove the item. + Throws ZMQPollException on error. + + + + + + + diff --git a/reference/zmq/zmqpoll/clear.xml b/reference/zmq/zmqpoll/clear.xml new file mode 100644 index 0000000..8e78a49 --- /dev/null +++ b/reference/zmq/zmqpoll/clear.xml @@ -0,0 +1,55 @@ + + + + + + ZMQPoll::clear + Clear the poll set + + + + &reftitle.description; + + public ZMQPollZMQPoll::clear + + + + Clears all elements from the poll set. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + Returns the current object. + + + + + + + diff --git a/reference/zmq/zmqpoll/count.xml b/reference/zmq/zmqpoll/count.xml new file mode 100644 index 0000000..2bc78c0 --- /dev/null +++ b/reference/zmq/zmqpoll/count.xml @@ -0,0 +1,55 @@ + + + + + + ZMQPoll::count + Count items in the poll set + + + + &reftitle.description; + + public intZMQPoll::count + + + + Count the items in the poll set. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + Returns an &integer; representing the amount of items in the poll set. + + + + + + + diff --git a/reference/zmq/zmqpoll/getlasterrors.xml b/reference/zmq/zmqpoll/getlasterrors.xml new file mode 100644 index 0000000..fa2dbc1 --- /dev/null +++ b/reference/zmq/zmqpoll/getlasterrors.xml @@ -0,0 +1,56 @@ + + + + + + ZMQPoll::getLastErrors + Get poll errors + + + + &reftitle.description; + + public arrayZMQPoll::getLastErrors + + + + Returns the ids of the objects that had errors in the last poll. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + Returns an array containing ids for the items that had errors in the last poll. Empty array is + returned if there were no errors. + + + + + + + diff --git a/reference/zmq/zmqpoll/poll.xml b/reference/zmq/zmqpoll/poll.xml new file mode 100644 index 0000000..5832557 --- /dev/null +++ b/reference/zmq/zmqpoll/poll.xml @@ -0,0 +1,172 @@ + + + + + + ZMQPoll::poll + Poll the items + + + + &reftitle.description; + + public intZMQPoll::poll + arrayreadable + arraywritable + inttimeout-1 + + + Polls the items in the current poll set. The readable and writable items are returned in the + readable and writable parameters. + ZMQPoll::getLastErrors can be used to check if there were errors. + + + + + &reftitle.parameters; + + + + readable + + + Array where readable ZMQSockets/PHP streams are returned. The array + will be cleared at the beginning of the operation. + + + + + writable + + + Array where writable ZMQSockets/PHP streams are returned. The array + will be cleared at the beginning of the operation. + + + + + timeout + + + Timeout for the operation. -1 means that poll waits until + at least one item has activity. Please note that starting from + version 1.0.0 the poll timeout is defined in milliseconds, rather + than microseconds. + + + + + + + + + &reftitle.returnvalues; + + Returns an integer representing the amount of items with activity. + + + + + &reftitle.errors; + + Throws ZMQPollException on error. + + + + + &reftitle.examples; + + + A <function>ZMQPoll</function> example + + Create a simple poll server + + +getSocket(ZMQ::SOCKET_REP); + +/* Bind to port 5555 on 127.0.0.1 */ +$server->bind("tcp://127.0.0.1:5555"); + +/* Create new pollset for incoming/outgoing message */ +$poll = new ZMQPoll(); + +/* Add the object and listen for poll in/out */ +$id = $poll->add($server, ZMQ::POLL_IN | ZMQ::POLL_OUT); +echo "Added object with id " . $id . "\n"; + +/* Initialise readable and writable arrays */ +$readable = array(); +$writable = array(); + +while (true) { + /* Amount of events retrieved */ + $events = 0; + + try { + /* Poll until there is something to do */ + $events = $poll->poll($readable, $writable, -1); + $errors = $poll->getLastErrors(); + + if (count($errors) > 0) { + foreach ($errors as $error) { + echo "Error polling object " . $error . "\n"; + } + } + } catch (ZMQPollException $e) { + echo "poll failed: " . $e->getMessage() . "\n"; + } + + if ($events > 0) { + /* Loop through readable objects and recv messages */ + foreach ($readable as $r) { + try { + echo "Received message: " . $r->recv() . "\n"; + } catch (ZMQException $e) { + echo "recv failed: " . $e->getMessage() . "\n"; + } + } + + /* Loop through writable and send back messages */ + foreach ($writable as $w) { + try { + $w->send("Got it!"); + } catch (ZMQException $e) { + echo "send failed: " . $e->getMessage() . "\n"; + } + } + } +} +?> +]]> + + + + + + + + diff --git a/reference/zmq/zmqpoll/remove.xml b/reference/zmq/zmqpoll/remove.xml new file mode 100644 index 0000000..f7dfdcc --- /dev/null +++ b/reference/zmq/zmqpoll/remove.xml @@ -0,0 +1,68 @@ + + + + + + ZMQPoll::remove + Remove item from poll set + + + + &reftitle.description; + + public boolZMQPoll::remove + mixeditem + + + Remove item from the poll set. The item parameter can be ZMQSocket object, + a stream resource or the id returned from ZMQPoll::add method. + + + + + &reftitle.parameters; + + + + item + + + The ZMQSocket object, PHP stream or &string; id of the item. + + + + + + + + + &reftitle.returnvalues; + + Returns true if the item was removed and false if the object + with given id does not exist in the poll set. + + + + + + + diff --git a/reference/zmq/zmqpollexception.xml b/reference/zmq/zmqpollexception.xml new file mode 100644 index 0000000..ec9ff4a --- /dev/null +++ b/reference/zmq/zmqpollexception.xml @@ -0,0 +1,112 @@ + + + + + + The ZMQPollException class + ZMQPollException + + + + +
+ &reftitle.intro; + + + +
+ + +
+ &reftitle.classsynopsis; + + + + ZMQPollException + + + + + ZMQPollException + + + + extends + ZMQException + + + + &Properties; + + + &Methods; + + + &InheritedMethods; + + + + + +
+ + + +
+ &reftitle.properties; + + + message + + + + + + code + + + + + + file + + + + + + line + + + + + +
+ + + +
+ + &reference.zmq.entities.zmqpollexception; + +
+ + diff --git a/reference/zmq/zmqsocket.xml b/reference/zmq/zmqsocket.xml new file mode 100644 index 0000000..b31f6ef --- /dev/null +++ b/reference/zmq/zmqsocket.xml @@ -0,0 +1,67 @@ + + + + + + The ZMQSocket class + ZMQSocket + + + + +
+ &reftitle.intro; + + + +
+ + +
+ &reftitle.classsynopsis; + + + + ZMQSocket + + + + + ZMQSocket + + + + + &Methods; + + + + +
+ +
+ + &reference.zmq.entities.zmqsocket; + +
+ + diff --git a/reference/zmq/zmqsocket/bind.xml b/reference/zmq/zmqsocket/bind.xml new file mode 100644 index 0000000..92a66e3 --- /dev/null +++ b/reference/zmq/zmqsocket/bind.xml @@ -0,0 +1,76 @@ + + + + + + ZMQSocket::bind + Bind the socket + + + + &reftitle.description; + + public ZMQSocketZMQSocket::bind + stringdsn + boolforce&false; + + + 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. + + + + + &reftitle.parameters; + + + + dsn + + + The bind dsn, for example transport://address. + + + + + force + + + Tries to bind even if the socket has already been bound to the given endpoint. + + + + + + + + + &reftitle.returnvalues; + + Returns the current object. Throws ZMQSocketException on error. + + + + + + + diff --git a/reference/zmq/zmqsocket/connect.xml b/reference/zmq/zmqsocket/connect.xml new file mode 100644 index 0000000..fe6612f --- /dev/null +++ b/reference/zmq/zmqsocket/connect.xml @@ -0,0 +1,122 @@ + + + + + + ZMQSocket::connect + Connect the socket + + + + &reftitle.description; + + public ZMQSocketZMQSocket::connect + stringdsn + boolforce&false; + + + 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. + + + + + &reftitle.parameters; + + + + dsn + + + The connect dsn, for example transport://address. + + + + + force + + + Tries to connect even if the socket has already been connected to given endpoint. + + + + + + + + + &reftitle.returnvalues; + + Returns the current object. + + + + + &reftitle.errors; + + Throws ZMQSocketException on error. + + + + + &reftitle.examples; + + + A <function>ZMQContext</function> example + + Construct a new context and allocate request socket from it + + +getEndpoints(); + +/* Check if the socket is connected */ +if (!in_array($dsn, $endpoints['connect'])) { + echo "

Connecting to $dsn

"; + $socket->connect($dsn); +} else { + echo "

Already connected to $dsn

"; +} + +/* Send and receive */ +$socket->send("Hello!"); +$message = $socket->recv(); + +echo "

Server said: {$message}

"; +?> +]]> +
+
+
+
+ +
+ + diff --git a/reference/zmq/zmqsocket/construct.xml b/reference/zmq/zmqsocket/construct.xml new file mode 100644 index 0000000..b6f7a2c --- /dev/null +++ b/reference/zmq/zmqsocket/construct.xml @@ -0,0 +1,142 @@ + + + + + + ZMQSocket::__construct + Construct a new ZMQSocket + + + + &reftitle.description; + + public ZMQSocket::__construct + ZMQContextcontext + inttype + stringpersistent_id&null; + callableon_new_socket&null; + + + Constructs a ZMQSocket object. 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. + + + + + &reftitle.parameters; + + + + context + + + ZMQContext object. + + + + + type + + + The socket type. See ZMQ::SOCKET_* constants. + + + + + persistent_id + + + If persistent_id is specified the socket will be persisted over multiple requests. + If context is not persistent the socket falls back to non-persistent mode. + + + + + on_new_socket + + + Callback function, which is executed when a new socket structure is created. This function does not get invoked + if the underlying persistent connection is re-used. + + + callback + ZMQSocketsocket + stringpersistent_id&null; + + + + + + + + + &reftitle.errors; + + Throws ZMQSocketException on error. + + + + + &reftitle.examples; + + + A <function>ZMQSocket</function> example + + Using callback the bind/connect socket + + +bind("tcp://localhost:12122"); + } else { + $socket->connect("tcp://localhost:12122"); + } +} + +/* Allocate a new context */ +$context = new ZMQContext(); + +/* Create a new socket */ +$socket = $context->getSocket(ZMQ::SOCKET_REP, 'server', 'on_new_socket_cb'); + +$message = $socket->recv(); +echo "Received message: {$message}\n"; +?> +]]> + + + + + + + + diff --git a/reference/zmq/zmqsocket/disconnect.xml b/reference/zmq/zmqsocket/disconnect.xml new file mode 100644 index 0000000..2b499c6 --- /dev/null +++ b/reference/zmq/zmqsocket/disconnect.xml @@ -0,0 +1,66 @@ + + + + + + ZMQSocket::disconnect + Disconnect a socket + + + + &reftitle.description; + + public ZMQSocketZMQSocket::disconnect + stringdsn + + + 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. + + + + + &reftitle.parameters; + + + + dsn + + + The connect dsn, for example transport://address. + + + + + + + + + &reftitle.returnvalues; + + Returns the current object. Throws ZMQSocketException on error. + + + + + + diff --git a/reference/zmq/zmqsocket/getendpoints.xml b/reference/zmq/zmqsocket/getendpoints.xml new file mode 100644 index 0000000..bc0a846 --- /dev/null +++ b/reference/zmq/zmqsocket/getendpoints.xml @@ -0,0 +1,54 @@ + + + + + + ZMQSocket::getEndpoints + Get list of endpoints + + + + &reftitle.description; + + public arrayZMQSocket::getEndpoints + + + + Returns a list of endpoints where the socket is connected or bound to. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + Returns an array containing elements 'bind' and 'connect'. + + + + + + diff --git a/reference/zmq/zmqsocket/getpersistentid.xml b/reference/zmq/zmqsocket/getpersistentid.xml new file mode 100644 index 0000000..c05ed42 --- /dev/null +++ b/reference/zmq/zmqsocket/getpersistentid.xml @@ -0,0 +1,55 @@ + + + + + + ZMQSocket::getPersistentId + Get the persistent id + + + + &reftitle.description; + + public stringZMQSocket::getPersistentId + + + + Returns the persistent id of the socket. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + Returns the persistent id string assigned of the object and &null; if socket is not persistent. + + + + + + + diff --git a/reference/zmq/zmqsocket/getsockettype.xml b/reference/zmq/zmqsocket/getsockettype.xml new file mode 100644 index 0000000..c4770fd --- /dev/null +++ b/reference/zmq/zmqsocket/getsockettype.xml @@ -0,0 +1,56 @@ + + + + + + ZMQSocket::getSocketType + Get the socket type + + + + &reftitle.description; + + public intZMQSocket::getSocketType + + + + Gets the socket type. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + Returns an integer representing the socket type. The integer can be compared against + ZMQ::SOCKET_* constants. + + + + + + + diff --git a/reference/zmq/zmqsocket/getsockopt.xml b/reference/zmq/zmqsocket/getsockopt.xml new file mode 100644 index 0000000..1630f35 --- /dev/null +++ b/reference/zmq/zmqsocket/getsockopt.xml @@ -0,0 +1,68 @@ + + + + + + ZMQSocket::getSockOpt + Get socket option + + + + &reftitle.description; + + public mixedZMQSocket::getSockOpt + stringkey + + + Returns the value of a socket option. + + + + + &reftitle.parameters; + + + + key + + + An integer representing the option. + See the ZMQ::SOCKOPT_* constants. + + + + + + + + + &reftitle.returnvalues; + + Returns either a &string; or an &integer; depending on key. Throws + ZMQSocketException on error. + + + + + + + diff --git a/reference/zmq/zmqsocket/ispersistent.xml b/reference/zmq/zmqsocket/ispersistent.xml new file mode 100644 index 0000000..0d7e31c --- /dev/null +++ b/reference/zmq/zmqsocket/ispersistent.xml @@ -0,0 +1,55 @@ + + + + + + ZMQSocket::isPersistent + Whether the socket is persistent + + + + &reftitle.description; + + public boolZMQSocket::isPersistent + + + + Check whether the socket is persistent. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + Returns a &boolean; based on whether the socket is persistent or not. + + + + + + + diff --git a/reference/zmq/zmqsocket/recv.xml b/reference/zmq/zmqsocket/recv.xml new file mode 100644 index 0000000..1800d9a --- /dev/null +++ b/reference/zmq/zmqsocket/recv.xml @@ -0,0 +1,135 @@ + + + + + + ZMQSocket::recv + Receives a message + + + + &reftitle.description; + + public stringZMQSocket::recv + intmode0 + + + Receive a message from a socket. By default receiving will block until a message is available unless + ZMQ::MODE_DONTWAIT flag is used. ZMQ::SOCKOPT_RCVMORE + socket option can be used for receiving multi-part messages. See ZMQSocket::setSockOpt + for more information. + + + + + &reftitle.parameters; + + + + mode + + + Pass mode flags to receive multipart messages or non-blocking operation. + See ZMQ::MODE_* constants. + + + + + + + + + &reftitle.returnvalues; + + Returns the message. If ZMQ::MODE_DONTWAIT + is used and the operation would block &false; shall be returned. + + + + + &reftitle.errors; + + Throws ZMQSocketException on error. + + + + + &reftitle.examples; + + + A send/recv example + + Non-blocking send / receive + + +connect("tcp://127.0.0.1:5555"); + +/* Assign socket 1 to the queue, send and receive */ +$retries = 5; +$sending = true; + +/* Start a loop */ +do { + try { + /* Try to send / receive */ + if ($sending) { + echo "Sending message\n"; + $queue->send("This is a message", ZMQ::MODE_DONTWAIT); + $sending = false; + } else { + echo "Got response: " . $queue->recv(ZMQ::MODE_DONTWAIT) . "\n"; + break; + } + } catch (ZMQSocketException $e) { + /* EAGAIN means that the operation would have blocked, retry */ + if ($e->getCode() === ZMQ::ERR_EAGAIN) { + echo " - Got EAGAIN, retrying ($retries)\n"; + } else { + die(" - Error: " . $e->getMessage()); + } + } + /* Sleep a bit between operations */ + usleep(5); +} while (--$retries); +?> +]]> + + &example.outputs.similar; + + + + + + + + + + diff --git a/reference/zmq/zmqsocket/recvmulti.xml b/reference/zmq/zmqsocket/recvmulti.xml new file mode 100644 index 0000000..a080bb9 --- /dev/null +++ b/reference/zmq/zmqsocket/recvmulti.xml @@ -0,0 +1,70 @@ + + + + + + ZMQSocket::recvMulti + Receives a multipart message + + + + &reftitle.description; + + public arrayZMQSocket::recvMulti + intmode0 + + + 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. + + + + + &reftitle.parameters; + + + + mode + + + Pass mode flags to receive multipart messages or non-blocking operation. + See ZMQ::MODE_* constants. + + + + + + + + + &reftitle.returnvalues; + + Returns the array of message parts. Throws ZMQSocketException in error. + If ZMQ::MODE_NOBLOCK is used and the operation would + block &boolean; false shall be returned. + + + + + + + diff --git a/reference/zmq/zmqsocket/send.xml b/reference/zmq/zmqsocket/send.xml new file mode 100644 index 0000000..f8adc4f --- /dev/null +++ b/reference/zmq/zmqsocket/send.xml @@ -0,0 +1,76 @@ + + + + + + ZMQSocket::send + Sends a message + + + + &reftitle.description; + + public ZMQSocketZMQSocket::send + stringmessage + intmode0 + + + Send a message using the socket. The operation can block unless ZMQ::MODE_NOBLOCK is used. + + + + + &reftitle.parameters; + + + + message + + + The message to send. + + + + + mode + + + Pass mode flags to receive multipart messages or non-blocking operation. + See ZMQ::MODE_* constants. + + + + + + + + + &reftitle.returnvalues; + + Returns the current object. Throws ZMQSocketException on error. + If ZMQ::MODE_NOBLOCK is used and the operation would + block &boolean; false shall be returned. + + + + + diff --git a/reference/zmq/zmqsocket/sendmulti.xml b/reference/zmq/zmqsocket/sendmulti.xml new file mode 100644 index 0000000..4e5b332 --- /dev/null +++ b/reference/zmq/zmqsocket/sendmulti.xml @@ -0,0 +1,76 @@ + + + + + + ZMQSocket::sendmulti + Sends a multipart message + + + + &reftitle.description; + + public ZMQSocketZMQSocket::sendmulti + arraymessage + intmode0 + + + Send a multipart message using the socket. The operation can block unless ZMQ::MODE_NOBLOCK is used. + + + + + &reftitle.parameters; + + + + message + + + The message to send - an array of strings + + + + + mode + + + Pass mode flags to receive multipart messages or non-blocking operation. + See ZMQ::MODE_* constants. + + + + + + + + + &reftitle.returnvalues; + + Returns the current object. Throws ZMQSocketException on error. + If ZMQ::MODE_NOBLOCK is used and the operation would + block &boolean; false shall be returned. + + + + + diff --git a/reference/zmq/zmqsocket/setsockopt.xml b/reference/zmq/zmqsocket/setsockopt.xml new file mode 100644 index 0000000..0a826c2 --- /dev/null +++ b/reference/zmq/zmqsocket/setsockopt.xml @@ -0,0 +1,76 @@ + + + + + + ZMQSocket::setSockOpt + Set a socket option + + + + &reftitle.description; + + public ZMQSocketZMQSocket::setSockOpt + intkey + mixedvalue + + + Sets a ZMQ socket option. The type of the value depends on the key. + See ZMQ Constant Types for more information. + + + + + &reftitle.parameters; + + + + key + + + One of the ZMQ::SOCKOPT_* constants. + + + + + value + + + The value of the parameter. + + + + + + + + + &reftitle.returnvalues; + + Returns the current object. Throws ZMQSocketException on error. + + + + + + + diff --git a/reference/zmq/zmqsocket/unbind.xml b/reference/zmq/zmqsocket/unbind.xml new file mode 100644 index 0000000..60eda03 --- /dev/null +++ b/reference/zmq/zmqsocket/unbind.xml @@ -0,0 +1,67 @@ + + + + + + ZMQSocket::unbind + Unbind the socket + + + + &reftitle.description; + + public ZMQSocketZMQSocket::unbind + stringdsn + + + 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. + + + + + &reftitle.parameters; + + + + dsn + + + The previously bound dsn, for example transport://address. + + + + + + + + + &reftitle.returnvalues; + + Returns the current object. Throws ZMQSocketException on error. + + + + + + + diff --git a/reference/zmq/zmqsocketexception.xml b/reference/zmq/zmqsocketexception.xml new file mode 100644 index 0000000..a83e5f6 --- /dev/null +++ b/reference/zmq/zmqsocketexception.xml @@ -0,0 +1,112 @@ + + + + + + The ZMQSocketException class + ZMQSocketException + + + + +
+ &reftitle.intro; + + + +
+ + +
+ &reftitle.classsynopsis; + + + + ZMQSocketException + + + + + ZMQSocketException + + + + extends + ZMQException + + + + &Properties; + + + &Methods; + + + &InheritedMethods; + + + + + +
+ + + +
+ &reftitle.properties; + + + message + + + + + + code + + + + + + file + + + + + + line + + + + + +
+ + + +
+ + &reference.zmq.entities.zmqsocketexception; + +
+ +