[nanomsg] Re: nn_bind issues

  • From: Dirkjan Ochtman <dirkjan@xxxxxxxxxx>
  • To: nanomsg <nanomsg@xxxxxxxxxxxxx>
  • Date: Sun, 17 Nov 2013 19:33:34 +0100

On Sun, Nov 17, 2013 at 5:24 PM, Matt Howlett <matt.howlett@xxxxxxxxx> wrote:
> What I'm trying to do is cycle through a range of ports and try and
> bind to them until i find a free one (because I start many identical
> processes on the same machine that all need to listen for messages -
> they are reducers in a map-reduce algorithm). I don't of course care
> what the port number is, so if there was a way to bind to "any free
> port", and subsequently find out what that is, that would also work.
> If this is possible, it's not obvious to me how to do it...

Wouldn't it make more sense to change the connect/bind sides?
Typically, you'd use connect for the side that doesn't care what port
it's on, and bind for the side that's stable. Unless of course you
have some M:N thing going on and are using an out-of-band mechanism to
communicate the port to connect to.

(Anyway, it sounds like nn_bind() should definitely return -1 and set
errno to EADDRINUSE instead of asserting, but I think Martin will jump
in on some point. It might make sense to file an issue with a reduced
test case, if possible?)

Cheers,

Dirkjan

Other related posts: