[zeromq-dev] ZMQ_FD with request sockets

Yi Ding yi.s.ding at gmail.com
Fri Dec 9 14:23:06 CET 2011


On 12/9/2011 2:36 AM, Mikko Koppanen wrote:
> 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.
Right, I get that it's edge-triggered.  What surprised me is that even
though there was a state change (from nothing on the wire ready to be
read to something is ready to be read) it wouldn't notify me unless I
had called recv before the state change happened.

>> 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
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev



More information about the zeromq-dev mailing list