[zeromq-dev] inproc: need to bind to an address before connect?

Pieter Hintjens ph at imatix.com
Fri Oct 19 06:03:43 CEST 2012


On Fri, Oct 19, 2012 at 7:45 AM, Chuck Remes <lists at chuckremes.com> wrote:

> No, it is not guaranteed that socket3 will be ready for a connection. All
> binds (and connects) happen asynchronously in the I/O thread. Depending on
> your machine performance, it could be ready in 10ms, 100ms or more.

Hmm, on inproc the connects and binds happen synchronously, so this is safe.

Here's the pattern that CZMQ uses for this (which has been heavily
tested and works):

- create one socket
- bind to inproc address
- create child thread and pass context
- child thread creates second socket
- child thread connects to inproc address

This works very well with PAIR sockets.

There is an explanation of the inproc:// behaviour on the zmq_inproc man page.

-Pieter



More information about the zeromq-dev mailing list