4 ms·
0mq is fantastic. I just wish it had some way to put a socket in a half-open state: http://stackoverflow.com/questions/3692854/how-should-a-zeromq-worker-safely
by endgame 16y ago
0mq is fantastic. I just wish it had some way to put a socket in a half-open state: http://stackoverflow.com/questions/3692854/how-should-a-zeromq-worker-safely-hang-up http://stackoverflow.com/questions/3692854/how-should-a-zero...
ETA: `zmq_poll()` is nice, but some way to make it play nicely with other event loops (like libev's) would be even better.
- pjscott 16y agoTo make 0MQ work with libev, get the file descriptor for each 0MQ socket: zmq_getsockopt(socket, ZMQ_FD, ¬ify_fd, ¬ify_fd_size) Then just pass notify_fd to libev, or libevent, or epoll, or whatever event library you prefer. Very pleasant and easy, but not yet officially documented last time I checked.
- jrockway 16y agoThis is not guaranteed to work. There is internal buffering and readabilty/writability is unrelated to the readability/writability of the underlying fd. You have to get ZMQ_EVENTS, check that readability/writability does not exist, and then make an IO watcher on the underlying fd. IIRC, you can't do this in pre-2.1.0 ZMQ; hence, using your own event loop is experimental. (I suppose it is also possible to see if you get EWOULDBLOCK during an IO operation, and then create the IO watcher, regular-socket-style.)
- jmtulloss 16y agoThis exists in ømq 2.1 (https://github.com/zeromq/zeromq2/tree/v2.1.0 https://github.com/zeromq/zeromq2/tree/v2.1.0). You can get access to the raw socket, which allows you to plug it into anything that understands sockets. This is what was done for zeromq.node to tie ømq into node.js.
- endgame 16y agoThanks for the pointer. How does this square up against jrockway's comment ( http://news.ycombinator.com/item?id=2055115 http://news.ycombinator.com/item?id=2055115 )?
- sophacles 16y agoI know Zed Shaw played with such things for making mongrel2. I've never needed it, so that is the best pointer I can provide, but the IRC channel for 0mq may be of help too -- friendly crowd over there.