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 <p...@colomiets.name> wrote:
> Hi Gerhard,
>
> On Fri, Apr 27, 2012 at 11:41 AM, Gerhard Lipp <gel...@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@lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to