[zeromq-dev] inproc sockets

Andrew Hume andrew at research.att.com
Tue May 21 00:25:41 CEST 2013


i observe that this works in simple cases, like i luckily have, but does not generalise.
for example, if each of two threads needs to do a bind, and a connect to the other's bind,
then this becomes a complicated dance.

i guess its not bad if all the binds are independent, and all the connects depend only on the binds.
but if any of this depends on other connections, then its really bad.
(but maybe it always is.)

On May 20, 2013, at 3:16 PM, Pieter Hintjens wrote:

> 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
> that.
>> 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
> threads.
> -Pieter
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Andrew Hume
623-551-2845 (VO and best)
973-236-2014 (NJ)
andrew at research.att.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130520/f0c9a525/attachment.htm>

More information about the zeromq-dev mailing list