2010-02-10 16:18:46 +01:00
|
|
|
zmq_poll(3)
|
|
|
|
===========
|
|
|
|
|
|
|
|
|
|
|
|
NAME
|
|
|
|
----
|
2010-03-09 18:47:31 +01:00
|
|
|
zmq_poll - input/output multiplexing
|
2010-02-10 16:18:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
--------
|
2010-03-09 18:47:31 +01:00
|
|
|
|
|
|
|
*int zmq_poll (zmq_pollitem_t '*items', int 'nitems', long 'timeout');*
|
2010-02-10 16:18:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
2010-03-09 18:47:31 +01:00
|
|
|
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 follows:
|
2010-02-10 16:18:46 +01:00
|
|
|
|
2010-03-09 18:47:31 +01:00
|
|
|
["literal", subs="quotes"]
|
2010-02-10 16:18:46 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2010-03-09 18:47:31 +01:00
|
|
|
void '*socket';
|
2021-05-16 08:50:06 -04:00
|
|
|
zmq_fd_t 'fd';
|
2010-03-09 18:47:31 +01:00
|
|
|
short 'events';
|
|
|
|
short 'revents';
|
2010-02-10 16:18:46 +01:00
|
|
|
} zmq_pollitem_t;
|
|
|
|
|
2010-03-09 18:47:31 +01:00
|
|
|
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 ignored.
|
|
|
|
|
|
|
|
For each *zmq_pollitem_t* item, _zmq_poll()_ shall first clear the 'revents'
|
2010-12-01 10:57:37 +01:00
|
|
|
member, and then indicate any requested events that have occurred by setting the
|
2010-03-09 18:47:31 +01:00
|
|
|
bit corresponding to the event condition in the 'revents' member.
|
|
|
|
|
2010-12-01 10:57:37 +01:00
|
|
|
If none of the requested events have occurred on any *zmq_pollitem_t* item,
|
2011-03-23 15:50:18 +01:00
|
|
|
_zmq_poll()_ shall wait 'timeout' milliseconds for an event to occur on
|
2010-03-10 12:19:39 +01:00
|
|
|
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
|
2010-12-01 10:57:37 +01:00
|
|
|
block indefinitely until a requested event has occurred on at least one
|
2010-03-10 12:19:39 +01:00
|
|
|
*zmq_pollitem_t*.
|
2010-03-09 18:47:31 +01:00
|
|
|
|
2010-12-01 10:57:37 +01:00
|
|
|
The 'events' and 'revents' members of *zmq_pollitem_t* are bit masks constructed
|
2010-03-09 18:47:31 +01:00
|
|
|
by OR'ing a combination of the following event flags:
|
2010-02-10 16:18:46 +01:00
|
|
|
|
|
|
|
*ZMQ_POLLIN*::
|
2010-06-02 18:36:34 +02:00
|
|
|
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.
|
2010-03-09 18:47:31 +01:00
|
|
|
|
2010-02-10 16:18:46 +01:00
|
|
|
*ZMQ_POLLOUT*::
|
2010-06-02 18:36:34 +02:00
|
|
|
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.
|
2010-03-09 18:47:31 +01:00
|
|
|
|
|
|
|
*ZMQ_POLLERR*::
|
|
|
|
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()_.
|
2010-02-10 16:18:46 +01:00
|
|
|
|
2014-10-17 17:21:41 +02:00
|
|
|
*ZMQ_POLLPRI*::
|
|
|
|
For 0MQ sockets this flags is of no use. For standard sockets this means there
|
2022-02-11 00:45:06 +02:00
|
|
|
is urgent data to read. Refer to the POLLPRI flag for more information.
|
2014-10-17 17:21:41 +02:00
|
|
|
For file descriptor, refer to your use case: as an example, GPIO interrupts
|
|
|
|
are signaled through a POLLPRI event.
|
|
|
|
This flag has no effect on Windows.
|
|
|
|
|
2010-03-09 18:47:31 +01:00
|
|
|
NOTE: 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 this documentation.
|
2010-02-10 16:18:46 +01:00
|
|
|
|
2020-01-19 09:54:11 +01:00
|
|
|
THREAD SAFETY
|
|
|
|
-------------
|
|
|
|
The *zmq_pollitem_t* array must only be used by the thread which
|
|
|
|
will/is calling _zmq_poll_.
|
|
|
|
|
|
|
|
If a socket is contained in multiple *zmq_pollitem_t* arrays, each owned by a
|
2022-02-11 00:45:06 +02:00
|
|
|
different thread, the socket itself needs to be thread-safe (Server, Client, ...).
|
2020-01-19 09:54:11 +01:00
|
|
|
Otherwise, behaviour is undefined.
|
|
|
|
|
|
|
|
|
2010-02-10 16:18:46 +01:00
|
|
|
RETURN VALUE
|
|
|
|
------------
|
2010-03-09 18:47:31 +01:00
|
|
|
Upon successful completion, the _zmq_poll()_ function shall return the number
|
2010-06-02 18:36:34 +02:00
|
|
|
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.
|
|
|
|
|
2010-02-10 16:18:46 +01:00
|
|
|
|
|
|
|
ERRORS
|
|
|
|
------
|
2010-04-12 09:25:04 +02:00
|
|
|
*ETERM*::
|
2010-06-01 22:22:29 +02:00
|
|
|
At least one of the members of the 'items' array refers to a 'socket' whose
|
|
|
|
associated 0MQ 'context' was terminated.
|
Added error checking (EFAULT) for null arguments
* Fixed zmq_term, zmq_socket, zmq_close, zmq_setsockopt,
* zmq_getsockopt, zmq_bind, zmq_connect, zmq_send,
* zmq_recv, zmq_poll, zmq_device, zmq_stopwatch_stop
* Updated Reference Manual for these methods
2010-08-08 11:43:32 +02:00
|
|
|
*EFAULT*::
|
|
|
|
The provided 'items' was not valid (NULL).
|
2010-09-08 08:39:27 +02:00
|
|
|
*EINTR*::
|
2010-12-01 10:57:37 +01:00
|
|
|
The operation was interrupted by delivery of a signal before any events were
|
|
|
|
available.
|
2010-02-10 16:18:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
EXAMPLE
|
|
|
|
-------
|
2010-09-04 15:54:34 +02:00
|
|
|
.Polling indefinitely for input events on both a 0MQ socket and a standard socket.
|
2010-02-10 16:18:46 +01:00
|
|
|
----
|
|
|
|
zmq_pollitem_t items [2];
|
2010-03-09 18:47:31 +01:00
|
|
|
/* First item refers to 0MQ socket 'socket' */
|
|
|
|
items[0].socket = socket;
|
|
|
|
items[0].events = ZMQ_POLLIN;
|
2010-09-04 15:54:34 +02:00
|
|
|
/* Second item refers to standard socket 'fd' */
|
2010-03-09 18:47:31 +01:00
|
|
|
items[1].socket = NULL;
|
|
|
|
items[1].fd = fd;
|
|
|
|
items[1].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 */
|
2010-02-10 16:18:46 +01:00
|
|
|
----
|
|
|
|
|
|
|
|
|
|
|
|
SEE ALSO
|
|
|
|
--------
|
|
|
|
linkzmq:zmq_socket[3]
|
2010-03-09 18:47:31 +01:00
|
|
|
linkzmq:zmq_send[3]
|
|
|
|
linkzmq:zmq_recv[3]
|
|
|
|
linkzmq:zmq[7]
|
2010-02-10 16:18:46 +01:00
|
|
|
|
2010-03-09 18:47:31 +01:00
|
|
|
Your operating system documentation for the _poll()_ system call.
|
2010-02-10 16:18:46 +01:00
|
|
|
|
2010-03-09 18:47:31 +01:00
|
|
|
|
2010-09-04 15:55:11 +02:00
|
|
|
AUTHORS
|
|
|
|
-------
|
2013-04-11 18:53:02 +02:00
|
|
|
This page was written by the 0MQ community. To make a change please
|
|
|
|
read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.
|