libzmq/man/man3/zmq_poll.3

66 lines
1.8 KiB
Groff
Raw Normal View History

2009-11-22 08:47:06 +01:00
.TH zmq_poll 3 "" "(c)2007-2009 FastMQ Inc." "0MQ User Manuals"
.SH NAME
zmq_poll \- polls for events on a set of 0MQ and POSIX sockets
.SH SYNOPSIS
.B int zmq_poll (zmq_pollitem_t *items, int nitems);
.SH DESCRIPTION
2009-11-23 09:22:25 +01:00
Waits for the events specified by
.IR items
parameter. Number of items in the array is determined by
.IR nitems
argument. Each item in the array looks like this:
.nf
typedef struct
{
void *socket;
int fd;
short events;
short revents;
} zmq_pollitem_t;
.fi
0MQ socket to poll on is specified by
.IR socket .
In case you want to poll on standard POSIX socket, set
.IR socket
to NULL and fill the POSIX file descriptor to
.IR fd .
.IR events
specifies which events to wait for. It's a combination of the values below.
Once the call exits,
.IR revent
will be filled with events that have actually occured on the socket. The field
will contain a combination of the following values.
.IP "\fBZMQ_POLLIN\fP"
poll for incoming messages.
.IP "\fBZMQ_POLLOUT\fP"
wait while message can be set socket. Poll will return if a message of at least
one byte can be written to the socket. However, there is no guarantee that
arbitrarily large message can be sent.
2009-11-22 08:47:06 +01:00
.SH RETURN VALUE
2009-11-23 09:22:25 +01:00
Function returns number of items signaled or -1 in the case of error.
2009-11-22 08:47:06 +01:00
.SH ERRORS
2009-11-23 09:22:25 +01:00
.IP "\fBEFAULT\fP"
there's a 0MQ socket in the pollset belonging to a different application thread.
.IP "\fBENOTSUP\fP"
0MQ context was initialised without ZMQ_POLL flag. I/O multiplexing is disabled.
2009-11-22 08:47:06 +01:00
.SH EXAMPLE
2009-11-23 09:22:25 +01:00
.nf
zmq_pollitem_t items [2];
items [0].socket = s;
2009-12-29 16:50:28 +01:00
items [0].events = ZMQ_POLLIN;
2009-11-23 09:22:25 +01:00
items [1].socket = NULL;
items [1].fd = my_fd;
2009-12-29 16:50:28 +01:00
items [1].events = ZMQ_POLLIN;
2009-11-23 09:22:25 +01:00
int rc = zmq_poll (items, 2);
assert (rc != -1);
.fi
2009-11-22 08:47:06 +01:00
.SH SEE ALSO
2009-11-23 09:22:25 +01:00
.BR zmq_socket (3)
2009-11-22 08:47:06 +01:00
.SH AUTHOR
Martin Sustrik <sustrik at 250bpm dot com>