[zeromq-dev] Setting RcvTimeout or polling with a timeout value?

Balázs Varga bb.varga at gmail.com
Fri Feb 1 13:13:57 CET 2013


If somebody want to set a timeout when receiving from a socket, there are
two approaches:

1. setting ZMQ_RCVTIMEO socket options and call zmq_recv()  which will set
error EAGAIN, if there's nothing in the queue


2. polling the socket with a given timeout?

zmq_pollitem_t items [] = { { socket,  0, ZMQ_POLLIN, 0 } };
int rc = zmq_poll (items, 1, timeout * ZMQ_POLL_MSEC);

which will return 0 if nothing to receive.

In the guide I see that the second method is widely used, however as I
remember I haven't met with the 1st approach. why is this, is it just a
choice, or are there any performance or other differences?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130201/e91ac45e/attachment.html>

More information about the zeromq-dev mailing list