1ZMQ_POLL(3)                       0MQ Manual                       ZMQ_POLL(3)
2
3
4

NAME

6       zmq_poll - input/output multiplexing
7

SYNOPSIS

9       int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout);
10

DESCRIPTION

12       The zmq_poll() function provides a mechanism for applications to
13       multiplex input/output events in a level-triggered fashion over a set
14       of sockets. Each member of the array pointed to by the items argument
15       is a zmq_pollitem_t structure. The nitems argument specifies the number
16       of items in the items array. The zmq_pollitem_t structure is defined as
17       follows:
18
19           typedef struct
20           {
21               void *socket;
22               int fd;
23               short events;
24               short revents;
25           } zmq_pollitem_t;
26
27       For each zmq_pollitem_t item, zmq_poll() shall examine either the 0MQ
28       socket referenced by socket or the standard socket specified by the
29       file descriptor fd, for the event(s) specified in events. If both
30       socket and fd are set in a single zmq_pollitem_t, the 0MQ socket
31       referenced by socket shall take precedence and the value of fd shall be
32       ignored.
33
34           Note
35           All 0MQ sockets passed to the zmq_poll() function must share the
36           same 0MQ context and must belong to the thread calling zmq_poll().
37
38       For each zmq_pollitem_t item, zmq_poll() shall first clear the revents
39       member, and then indicate any requested events that have occurred by
40       setting the bit corresponding to the event condition in the revents
41       member.
42
43       If none of the requested events have occurred on any zmq_pollitem_t
44       item, zmq_poll() shall wait timeout microseconds for an event to occur
45       on any of the requested items. If the value of timeout is 0, zmq_poll()
46       shall return immediately. If the value of timeout is -1, zmq_poll()
47       shall block indefinitely until a requested event has occurred on at
48       least one zmq_pollitem_t.
49
50       The events and revents members of zmq_pollitem_t are bit masks
51       constructed by OR’ing a combination of the following event flags:
52
53       ZMQ_POLLIN
54           For 0MQ sockets, at least one message may be received from the
55           socket without blocking. For standard sockets this is equivalent to
56           the POLLIN flag of the poll() system call and generally means that
57           at least one byte of data may be read from fd without blocking.
58
59       ZMQ_POLLOUT
60           For 0MQ sockets, at least one message may be sent to the socket
61           without blocking. For standard sockets this is equivalent to the
62           POLLOUT flag of the poll() system call and generally means that at
63           least one byte of data may be written to fd without blocking.
64
65       ZMQ_POLLERR
66           For standard sockets, this flag is passed through zmq_poll() to the
67           underlying poll() system call and generally means that some sort of
68           error condition is present on the socket specified by fd. For 0MQ
69           sockets this flag has no effect if set in events, and shall never
70           be returned in revents by zmq_poll().
71
72           Note
73           The zmq_poll() function may be implemented or emulated using
74           operating system interfaces other than poll(), and as such may be
75           subject to the limits of those interfaces in ways not defined in
76           this documentation.
77

RETURN VALUE

79       Upon successful completion, the zmq_poll() function shall return the
80       number of zmq_pollitem_t structures with events signaled in revents or
81       0 if no events have been signaled. Upon failure, zmq_poll() shall
82       return -1 and set errno to one of the values defined below.
83

ERRORS

85       ETERM
86           At least one of the members of the items array refers to a socket
87           whose associated 0MQ context was terminated.
88
89       EFAULT
90           The provided items was not valid (NULL).
91
92       EINTR
93           The operation was interrupted by delivery of a signal before any
94           events were available.
95

EXAMPLE

97       Polling indefinitely for input events on both a 0MQ socket and a
98       standard socket..
99
100           zmq_pollitem_t items [2];
101           /* First item refers to 0MQ socket 'socket' */
102           items[0].socket = socket;
103           items[0].events = ZMQ_POLLIN;
104           /* Second item refers to standard socket 'fd' */
105           items[1].socket = NULL;
106           items[1].fd = fd;
107           items[1].events = ZMQ_POLLIN;
108           /* Poll for events indefinitely */
109           int rc = zmq_poll (items, 2, -1);
110           assert (rc >= 0);
111           /* Returned events will be stored in items[].revents */
112
113

SEE ALSO

115       zmq_socket(3) zmq_send(3) zmq_recv(3) zmq(7)
116
117       Your operating system documentation for the poll() system call.
118

AUTHORS

120       This 0MQ manual page was written by Martin Sustrik
121       <sustrik@250bpm.com[1]> and Martin Lucina <mato@kotelna.sk[2]>.
122

NOTES

124        1. sustrik@250bpm.com
125           mailto:sustrik@250bpm.com
126
127        2. mato@kotelna.sk
128           mailto:mato@kotelna.sk
129
130
131
1320MQ 2.1.4                         03/30/2011                       ZMQ_POLL(3)
Impressum