[zeromq-dev] Proposal for synchronous connect option

Pieter Hintjens ph at imatix.com
Mon Feb 21 18:45:55 CET 2011


Many people, IMO, stumble on the zmq_connect call due to the fact it's
async and can take an arbitrary time to complete, in the background.
It's a recurrent trap for new users doing pubsub.

We already have some handshaking over TCP/IPC, where the connecting
node (client) sends its identity to the binding node (server). How
about if we send back an acknowledgement from the server to client,
and allow the application to wait for this?

This would simplify a fair number of use cases, where people (for
example) use a req/rep dialog to synchronize two nodes before starting
a pubsub dialog. I've found that even that does not work consistently,
since connects can be delayed quite some time especially if there's a
lot of message transfer happening.

I'd suggest keeping the asynchronous semantics for zmq_connect but
adding perhaps a getsockopt that returns the connected status, waiting
for some decent time to allow apps to detect connection failures.

This could be done without breaking existing apps, using the flags
byte on that initial identity message.


More information about the zeromq-dev mailing list