[nanomsg] Re: How to bind on a random port?

  • From: Matt Howlett <matt.howlett@xxxxxxxxx>
  • To: nanomsg <nanomsg@xxxxxxxxxxxxx>
  • Date: Sun, 16 Nov 2014 11:45:28 +0700

>
> It should be treated as a failure to connect. The implementation
> should try to re-connect assuming that the interface will become
> available eventually.
>

I think it would be very common for people to want an atomic way of
checking if a port is free, binding to it if it is, and moving on if it is
not (I want this and I notice a number of others here do too). I also think
that in most scenarios where a port is already in use, it's likely to stay
that way for a time period long enough that the application wanting to bind
to it is not going to find it useful to wait for it to become free (I'm not
an expert though and could be missing a common scenario where this
functionality is actually useful - examples?). So based on that, I think
the former behavior is the best, or should at least be an option.

Other related posts: