[zeromq-dev] socket writability and events

Justin Karneges justin at affinix.com
Fri Dec 14 21:40:41 CET 2012


Is it possible that a socket could be determined to be writable but then 
actually isn't writable at the time of write? For example, say a connection 
exists on a bind socket and ZMQ_POLLOUT is indicated. But then just before 
calling zmq_send(), the connection is destroyed. A socket that was using bind 
should have no queue anymore, and therefore I would expect the send to 
actually block (or report EAGAIN). I just want to confirm this is indeed 

Secondly, assuming the above is true, if you're doing an event loop 
integration and checking ZMQ_EVENTS after every call to zmq_send, do you still 
need to check the events even if zmq_send fails? My guess is that if it fails 
with EAGAIN, that you probably should check the events (especially if the 
reason you attempted a write in the first place is because ZMQ_POLLOUT was 
indicated prior). What I'm doing in my code now is checking events after 
success or EAGAIN, but not checking in any other case. Looking for confirmation 
on this as well.


More information about the zeromq-dev mailing list