[zeromq-dev] External Event Loop

Praveen Baratam praveen.baratam+zmq at gmail.com
Tue Jan 25 08:28:22 CET 2011


Hello All,

I have previously raised an issue on this mailing list that integration of
ZMQ sockets with external event loops is not working. You can review the
testcase from my previous mail to understand where and how its failing.

Here is a work around for this problem.

Actually when sockets are created and bound/connected they are not ready for
polling using ZMQ_FD. We have to do a non-blocking read on them until EAGAIN
is returned in which case the internal state (only guess) is set as
non-readable. Now when we poll using ZMQ_FD and if the socket becomes
readable then we get a event. And on receiving an event we again have to
read till EAGAIN is returned to ensure that the socket is sent back to
non-readable state before polling again. Thats how edge-triggered event
mechanism works.

The whole thing is fine, except that there is no example integrating
ZMQ_SOCKETS with external event mechanisms like select, poll, epoll, etc.
More over the above method is not documented anywhere. One more thing
regarding ZMQ_FD is that it is edge triggered. This statement doesnt mean
that it can be used only with edge-triggered event reactors but that ZMQ_FD
is signalled in an edge triggered way. You can use normal level-triggered
event reactors to monitor ZMQ_FD but make sure you follow the guidelines
outlined above.

Here I am attaching a simple example / test case integrating ZMQ_FD with
poll for reference.

Thank you Martin for your time and guidance.

Regards,

Praveen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110125/711b0574/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TestCase.cpp
Type: text/x-c++src
Size: 4501 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110125/711b0574/attachment.cpp>


More information about the zeromq-dev mailing list