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

Kah-Chan Low kahchanlow at yahoo.com
Thu Oct 18 19:29:05 CEST 2012


Thanks Chuck and Lourens for your very speedy reply!

I have two threads and to overcome this problem I have set-up the code like this:
Thread A is guaranteed to execute the relevant parts of the code first even before Thread B gets started.

Thread A
----------
.
.

socket1.bind("inproc://addr1");
socket1.blockingrecv();
socket2.connect("inproc://addr2");

.
.

Thread B
----------
.
.
.
socket3.bind("inproc://addr2");
socket4.connect("inproc://addr1");
socket.send(msg);
.
.
.

Is this guaranteed to work?
My question is this: after socket3.bind() is done and right before socket4.connect() is executed, is socket3 guaranteed to be ready for connection?


Thanks!
KC


________________________________
 From: Chuck Remes <lists at chuckremes.com>
To: Kah-Chan Low <kahchanlow at yahoo.com>; ZeroMQ development list <zeromq-dev at lists.zeromq.org> 
Sent: Thursday, October 18, 2012 12:57 PM
Subject: Re: [zeromq-dev] inproc: need to bind to an address before connect?
 

It's a long-standing bug that is very difficult to fix. The work around is to do as you discovered which is *always bind first* and then connect when using inproc transport.

For details as to why this is hard, try searching the mailing list archive. The answer would have been given by Martin Sustrik. You can also check the bug database for a write-up on this.

cr


On Oct 18, 2012, at 11:55 AM, Kah-Chan Low wrote:

Hi,
>When I do this I will get a "connection refused" error:
>
>
>socket1.connect("inproc://abc");
>socket2.bind("inproc://abc");
>
>
>When I reverse the order of the statements everything works fine.
>Both sockets have been created with the same ZMQ context.
>
>
>Is this a feature or a bug?
>
>
>Thanks!
>KC
>
>
>
>_______________________________________________
>zeromq-dev mailing list
>zeromq-dev at lists.zeromq.org
>http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20121018/735aa5cc/attachment.htm>


More information about the zeromq-dev mailing list