[zeromq-dev] inproc sockets

Pieter Hintjens ph at imatix.com
Tue May 21 00:16:22 CEST 2013

On Mon, May 20, 2013 at 5:29 PM, Andrew Hume <andrew at research.att.com> wrote:

> what is the preferred mechanism for having threads talk to one another?

CZMQ's zthread_fork method does this in a way that seems robust and simple.

Parent thread creates two sockets, binds one, connects the other,
creates a thread, and passes it one end of the pipe. The child thread
can then talk to the parent over the pipe. We use PAIR sockets for

> the old way was for the main program to do the bind
> before spawning threads who do the connect,
> and passing that bind socket to teh thread who needs it.

Yes, this is the other pattern we use (in the Guide examples): parent
creates socket and binds it, then starts child threads, which connect.

> the new meme talks about creating sockets within threads
> but it is awkward to arrange the bind first.

The only complex part is when you want different sub-threads to
connect safely; in that case I use the pipe mechanism to signal
"ready" from threads, back to the main, before starting further


More information about the zeromq-dev mailing list