[zeromq-dev] Using system select with ZMQ Dealer/Router and Multi-Part messages
t.scharnberg at wenzel-elektronik.de
Mon Feb 11 14:45:55 CET 2013
I'm trying to use a Dealer and a Router socket in combination with
system select() instead of zmq_poll. We do use an event class in our
projects that is based on select, so I tried to use this instead of
I wrote two test programs. Both use select() for READ events on the
dealer socket and on the router socket, and I do check the ZMQ_EVENTS
type if the event fires.
One part (ZMQ Dealer) repeatedly sends a multipart message to the ZMQ
Router test program.
The ZMQ Router gets READ event from select for the first message, and I
read the full multipart message from the socket. But after that I don't
get another event - until I stop the ZMQ Dealer test program, then I
receive the SECOND sent message.
I did read in the API that I do have to check the ZMQ_EVENTS after each
zmq_send(), which I do after reading all parts of the multipart message.
Do I need to check the ZMQ_EVENTS after every read? Even if I'm in the
middle of receiving a multipart message?
Do I need to do the same after each zmq_rcv() on the other side, even
though I dont send anything there?
Copied Text from API:
The returned file descriptor is also used internally by the zmq_send and
zmq_recv functions. As the descriptor is edge triggered, applications
must update the state of ZMQ_EVENTS after each invocation of zmq_send or
zmq_recv.To be more explicit: after calling zmq_send the socket may
become readable (and vice versa) without triggering a read event on the
What does "applications must update the state of ZMQ_EVENTS after each
invocation of zmq_send or zmq_recv" exactly mean? I'm using
zmq_getsockopt - does this update the ZMQ_EVENTS ?
I did a search in the mailing list, found some other mailings around the
same topic, but I am still a little bit confused. Hope you can help me
clear things up.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the zeromq-dev