[zeromq-dev] ZMQ_FD with request sockets
Mikko Koppanen
mikko at kuut.io
Fri Dec 9 09:36:42 CET 2011
On Fri, Dec 9, 2011 at 1:02 AM, Yi Ding <yi.s.ding at gmail.com> wrote:
> I guess there is a difference in behavior to how ZMQ_FD works and
> zmq_poll. When using ZMQ_FD I don't even get the signal if I don't call
> recv first (the timing doesn't matter, I can send out a reply 10 seconds
> later and I still won't get a notification on the ZMQ_FD unless I've
> called recv before.
just to clarify this further: ZMQ_FD is edge-triggered where as
zmq_poll operates on level-triggered way. I tripped on this some time
ago as well. ZMQ_FD will only trigger state changes, which means that
3 messages in the pipe will only trigger one POLLIN event and all
messages need to be read in the callback in non-blocking fashion. With
zmq_poll the POLLIN is triggered as long as there are messages in the
pipe so if you don't read the messages in the callback the event will
trigger over and over.
> Another thing is that calling recv on a ZMQ_REQ socket that I've already
> recv'd from, even if NOBLOCK is enabled, will return EFSM.
You should look into ROUTER and DEALER sockets which don't force
strict pattern like REQ/REP.
Thanks,
Miko
More information about the zeromq-dev
mailing list