Provided by: libzmq-dev_2.1.11-1ubuntu1_i386
zmq_poll - input/output multiplexing
int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout);
The zmq_poll() function provides a mechanism for applications to
multiplex input/output events in a level-triggered fashion over a set
of sockets. Each member of the array pointed to by the items argument
is a zmq_pollitem_t structure. The nitems argument specifies the number
of items in the items array. The zmq_pollitem_t structure is defined as
For each zmq_pollitem_t item, zmq_poll() shall examine either the 0MQ
socket referenced by socket or the standard socket specified by the
file descriptor fd, for the event(s) specified in events. If both
socket and fd are set in a single zmq_pollitem_t, the 0MQ socket
referenced by socket shall take precedence and the value of fd shall be
All 0MQ sockets passed to the zmq_poll() function must share the
same 0MQ context and must belong to the thread calling zmq_poll().
For each zmq_pollitem_t item, zmq_poll() shall first clear the revents
member, and then indicate any requested events that have occurred by
setting the bit corresponding to the event condition in the revents
If none of the requested events have occurred on any zmq_pollitem_t
item, zmq_poll() shall wait timeout microseconds for an event to occur
on any of the requested items. If the value of timeout is 0, zmq_poll()
shall return immediately. If the value of timeout is -1, zmq_poll()
shall block indefinitely until a requested event has occurred on at
least one zmq_pollitem_t. The resolution of timeout is 1 millisecond.
The events and revents members of zmq_pollitem_t are bit masks
constructed by OR'ing a combination of the following event flags:
For 0MQ sockets, at least one message may be received from the
socket without blocking. For standard sockets this is equivalent to
the POLLIN flag of the poll() system call and generally means that
at least one byte of data may be read from fd without blocking.
For 0MQ sockets, at least one message may be sent to the socket
without blocking. For standard sockets this is equivalent to the
POLLOUT flag of the poll() system call and generally means that at
least one byte of data may be written to fd without blocking.
For standard sockets, this flag is passed through zmq_poll() to the
underlying poll() system call and generally means that some sort of
error condition is present on the socket specified by fd. For 0MQ
sockets this flag has no effect if set in events, and shall never
be returned in revents by zmq_poll().
The zmq_poll() function may be implemented or emulated using
operating system interfaces other than poll(), and as such may be
subject to the limits of those interfaces in ways not defined in
Upon successful completion, the zmq_poll() function shall return the
number of zmq_pollitem_t structures with events signaled in revents or
0 if no events have been signaled. Upon failure, zmq_poll() shall
return -1 and set errno to one of the values defined below.
At least one of the members of the items array refers to a socket
whose associated 0MQ context was terminated.
The provided items was not valid (NULL).
The operation was interrupted by delivery of a signal before any
events were available.
Polling indefinitely for input events on both a 0MQ socket and a
zmq_pollitem_t items ;
/* First item refers to 0MQ socket 'socket' */
items.socket = socket;
items.events = ZMQ_POLLIN;
/* Second item refers to standard socket 'fd' */
items.socket = NULL;
items.fd = fd;
items.events = ZMQ_POLLIN;
/* Poll for events indefinitely */
int rc = zmq_poll (items, 2, -1);
assert (rc >= 0);
/* Returned events will be stored in items.revents */
zmq_socket(3) zmq_send(3) zmq_recv(3) zmq(7)
Your operating system documentation for the poll() system call.
This 0MQ manual page was written by Martin Sustrik
<email@example.com> and Martin Lucina <firstname.lastname@example.org>.