[zeromq-dev] Polling on a REQUEST socket

Martin Sustrik sustrik at 250bpm.com
Mon Apr 12 14:54:51 CEST 2010


Hi Andreas,

> The client opens two sockets (one REQUEST and one REPLY socket).
> Then, it connects the REQUEST socket to the server's REPLY socket
> and sends a register message. Afterwards it should wait for the server's
> reply. To deal with crashing servers, I used zmq_poll() with a 5 seconds
> timeout. The problem now is that the zmq_poll() immediately returns
> with return code 0 (timeout occured) and no errno is set.
> 
> If I use -1 as timeout instead, everthing runs fine. If I use a sleep(1)
> before the poll, everything is okay, too.
> 
> The REPLY socket has no problem with the zmq_poll() function. It
> behaves exactly as it should do.

See the docs:

"If none of the requested events have occured on any zmq_pollitem_t 
item, zmq_poll() shall wait up to timeout microseconds for an event to 
occur on any of the requested items."

Notice the "up to" part. zmq_poll can exit earlier but should never exit 
later than the timeout specified.

Martin



More information about the zeromq-dev mailing list