[zeromq-dev] What are the “serious caveats” with ZMQ_FD?

Kalle Huttunen khuttun at gmail.com
Sat Apr 30 21:32:56 CEST 2016

The ZeroMQ FAQ (http://zeromq.org/area:faq#toc5) states in the "Why can't I
use standard I/O multiplexing functions such as select() or poll() on
ZeroMQ sockets?" question:

> Note that there's a way to retrieve a file descriptor from ZeroMQ socket
(ZMQ_FD socket option) that you can poll on from version 2.1 onwards,
however, there are some serious caveats when using it. Check the
documentation carefully before using this feature.

I've prototyped integrating ZeroMQ socket receiving to Qt's and custom
select() based event loops, and on the first glance everything seems to

>From the documentation I have identified two "caveats" that I handle in my

1. The ability to read from the returned file descriptor does not
necessarily indicate that messages are available to be read from the socket

This I have solved by checking ZMQ_EVENTS before reading from the socket.

2. Events are signaled in edge-triggered fashion

This one I have solved by always receiving all the messages from the socket
when the file descriptor signals.

Are there some caveats that I'm missing?

Kalle Huttunen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20160430/59b2ec3e/attachment.htm>

More information about the zeromq-dev mailing list