[zeromq-dev] ZMQ_POLLIN received on WRITE event

Dorvin dorvin at tlen.pl
Thu Sep 25 11:09:15 CEST 2014

Thank you for your replies so far. I'll clarify if it does matter that 
I'm using Windows and libzmq 4.0.4.

W dniu 2014-09-25 04:38, Goswin von Brederlow pisze:
>the ØMQ library
>      shall signal any pending events on the socket in an edge-triggered
>      fashion by making the file descriptor become ready for reading.
This is exactly what bothers me. According to documentation I'm supposed 
to get most socket events when FD gets ready for reading.

But when I do:
sel_ret = select(sub_fd + 1, &sub_set, NULL, NULL, &time );
if (sel_ret == 1)
     zmq_getsockopt(subscriber, ZMQ_EVENTS, &zevents, &zevents_len);
     if(zevents & ZMQ_POLLIN)
         //retrieve and do something with message

I receive only some or none messages at all. You may see it in testcase.

For now I found 3 options to work this out:
1. Use zmq_poll() periodically - this seems to get read and write 
notifications at the same time and therefore not lose events. This does 
not look like event-driven way of doing things, though.
2. Use getsockopt with ZMQ_EVENTS after each send or receive - this is 
like small version of zmq_poll invoked almost constantly.
3. Keeping write notifier active all time which is not a good idea 
because it fires on every pass of event loop. In first reply I already 
was discouraged from this option.

If you would be so kind I would ask you to execute my code, see results 
and tell me if it's expected behavior (some kind of optimization or 
something), I miss something in how 0mq sockets should work, or if I 
should file bug report.

You may remove line "if (occurences > 0) {break;};" to see that what I 
describe is not single event but it repeats.

With regards,

More information about the zeromq-dev mailing list