Hello,

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

and

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?

thx

b.
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to