[zeromq-dev] missing events ZMQ_FD / ZMQ_EVENTS

Gerhard Lipp gelipp at googlemail.com
Fri Apr 27 11:37:26 CEST 2012


I don't think it is a docu thing.

What the docu says  (and what the source looks like)
zmq_getsockopt(ZMQ_FD) returns a fd (the mailbox's), which becomes
readable, whenever the corresponding socket might have become readable
and/or writeable for operation with the NOBLOCK option. To check which
of these conditions are true, you have to use
zmq_getsockopt(ZMQ_EVENTS) and check for ZMQ_POLLIN / ZMQ_POLLOUT
respectively.

If this is true, users should ONLY select/poll for the read event,
e.g. using libev EV_READ, regardless if the user wants to
zmq_recv(ZMQ_NOBLOCK) or zmq_send(ZMQ_NOBLOCK). Then the example code
shows a bug or I am using the XREQ/XREP in a wrong way.

Else, you are right and the documentation has to be updated to
select/poll for read AND write events.

I guess the "solution/workaround" of the example (using ev.READ +
ev.WRITE) does not work reliable and under all circumstances, but just
in this primitive scenario.

greets

On Fri, Apr 27, 2012 at 11:07 AM, Paul Colomiets <paul at colomiets.name> wrote:
> Hi Gerhard,
>
> On Fri, Apr 27, 2012 at 11:41 AM, Gerhard Lipp <gelipp at googlemail.com> wrote:
>>> Probably I don't understand the code. You must poll only for reading
>>> on ZMQ_FD. But every zmq_send and zmq_recv cosumes mailbox.
>>> Which means you must update you applications' state of readable
>>> and writable flags (I mean your IO framework doesn't know that
>>> socket became readable or writable).
>>>
>>> If you don't care about ZMQ_POLLOUT event, you still must check
>>> ZMQ_EVENTS for reading on each zmq_send.
>>
>> You are right, I am actually just waiting to be able to zmq_recv with
>> ZMQ_NOBLOCK. I dont care about the ZMQ_POLLOUT in this example. As the
>> docs state, either event is signaled by the mailbox (ZMQ_FD) becoming
>> ready to read (ev.READ). That is why i am checking for ZMQ_POLLIN
>> before entering the zmq_recv/zmq_send.
>>
>
> So the real problem is misleading documentation? I think it would
> be nice if you'd update documentation in a way that's understandable
> for you, and send a pull request.
>
> --
> Paul
> _______________________________________________
> 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