Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UdpBuilder.reuse_address does not work on OS X #46

Open
oyiptong opened this issue Jan 11, 2017 · 4 comments
Open

UdpBuilder.reuse_address does not work on OS X #46

oyiptong opened this issue Jan 11, 2017 · 4 comments

Comments

@oyiptong
Copy link

UdpBuilder.reuse_address seems to work fine on Linux but not on OS X

@alexcrichton
Copy link
Contributor

Maybe this option just isn't supported on OSX? What's the error you're seeing?

@oyiptong
Copy link
Author

The only error i see on OS X is "address in use".

Digging further into this, I tried to use SO_REUSEPORT and that seems to work on OS X. Perhaps SO_REUSEADDR isn't supported by Darwin?

@alexcrichton
Copy link
Contributor

Perhaps? I forget the specifics here of how cross platform this API is...

@DoumanAsh
Copy link
Contributor

DoumanAsh commented Jan 28, 2017

@oyiptong it depends on how to interpret you these options

SO_REUSEADDR

Indicates that the rules used in validating addresses supplied
in a bind(2) call should allow reuse of local addresses. For
AF_INET sockets this means that a socket may bind, except when
there is an active listening socket bound to the address.

In short: if you bind "192.168.0.1:21", and another socket attempts to bind to "0.0.0.0:21" it will fail without option

SO_REUSEPORT

Permits multiple AF_INET or AF_INET6 sockets to be bound to an
identical socket address. This option must be set on each
socket (including the first socket) prior to calling bind(2)
on the socket. To prevent port hijacking, all of the
processes binding to the same address must have the same
effective UID. This option can be employed with both TCP and
UDP sockets.

In short: you can bind to the SAME address as much sockets, as you want as long as they all have this option set.

P.s. see http://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants