[zeromq-dev] blocking

john skaller skaller at users.sourceforge.net
Sun Jan 22 03:37:42 CET 2012

On 22/01/2012, at 11:32 AM, Martin Sustrik wrote:

> On 21/01/12 23:34, john skaller wrote:
>> Which ops in 0MQ can block?
>> I know these can block:
>> send/recv/send_msg/recv_msg
>> close
>> term
> These are blocking: send, sendmsg, recv, recvmsg, poll, term.
> Note that zmq_close() is never blocking.

Ah, ok. Thanks.

> Yes. No problem with that. You can either use zmq_poll() for your main event loop, or, if you want to use OS's native polling mechanism, you can get an file descriptor to poll on using ZMQ_FD option.

Curious .. how can that be? A ZeroMQ socket can be attached to multiple endpoints.
Underneath this must mean multiple OS sockets?

BTW: I'd like to get rid of the fd in the poll-items, it destroys platform independence.
Anyhow, I can do that in my binding easily.

Another observation: 0MQ poll looks like select. That really sucks.
It doesn't scale. If you have a lot of sockets you have to search through 
an array to find the one that's active: O(N) performance.

The least poll could do would be to give you an array of only the active ones.

Arrays are also hopeless at supporting deletions (insertion is
fine since ordering doesn't matter here, new items can just go
on the end)..

john skaller
skaller at users.sourceforge.net

More information about the zeromq-dev mailing list