[zeromq-dev] ZMQ_EVENTS and ZMQ_FD work in progress (was Re: zmq_poll: timeout issue)

Martin Lucina mato at kotelna.sk
Tue Aug 10 17:24:57 CEST 2010

matt_weinstein at yahoo.com said:
> ZMQ_FD and ZMQ_EVENTS appear to return the current status of a socket,  
> am I right?

The idea is that you call

    zmq_getsockopt(socket, ZMQ_FD, &notify_fd, &notify_fd_size)

This gives you a plain old file descriptor, notify_fd, which you can poll
for input on in your own polling loop.

When notify_fd becomes ready for input this indicates that "something"
happened on the socket in question. You then call

    zmq_getsockopt(socket, ZMQ_EVENTS, &zmq_events, &zmq_events_size)

Which gives you back a mask of the actual ZMQ_POLLIN/ZMQ_POLLOUT events for
that socket.

This means that you will be able to transparently integrate 0MQ sockets
into any external poll loop.

/me makes a note to self to announce this work in progress branch properly.
Sorry for not doing this so far, but there are too many things happening
right now :-(

> I looked at the poll() code but it looks pretty vanilla, list of  
> timers ... except for the cross-thread counter, which would be nice,  
> is that what I'm seeing ...?

The zmq_poll() code is intentionally very vanilla and right now just works
the same as the existing poll. The wip-shutdown branch needs to stabilize
before writing new code on there ...

I'd also like to look at your poll reactor -- I think a discussion on an
improved polling API for 0MQ will be very relevant in the near future.



More information about the zeromq-dev mailing list