[zeromq-dev] ZMQ_POLLIN received on WRITE event
Goswin von Brederlow
goswin-v-b at web.de
Thu Sep 25 04:38:30 CEST 2014
On Wed, Sep 24, 2014 at 07:51:39PM +0200, Dorvin wrote:
> Hi,
>
> I started using ZeroMQ not long ago and tried to use it in evented app.
> When I try to use FD with socket notifier it appears I'm receiving
> ZMQ_POLLIN events when FD is signalling write event. Is there any
> rationale behind such behavior?
>
> Naive testcase to show this behavior is at: http://pastebin.com/iXV2GVVv
>
>
> Thanks in advance for you reply,
> Jarek
>From http://api.zeromq.org/4-1:zmq-getsockopt:
ZMQ_FD: Retrieve file descriptor associated with the socket
The ZMQ_FD option shall retrieve the file descriptor associated
with the specified socket. The returned file descriptor can be used to
integrate the socket into an existing event loop; 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.
The FD isn't the actual lowlevel socket. Instead it is a signalfd or
eventfd or something like it. The IO threads write to it when
something happens on any of the low-level socket attached to the zmq
socket and the event handler reads from it to clear it again.
The ability to read from the returned file descriptor does not
necessarily indicate that messages are available to be read from,
or can be written to, the underlying socket; applications must
retrieve the actual event state with a subsequent retrieval of the
ZMQ_EVENTS option.
MfG
Goswin
More information about the zeromq-dev
mailing list