Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
unix: explain SO_REUSEADDR and SO_REUSEPORT
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Jan 31, 2012
1 parent cd16ba5 commit 45d7bd8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/unix/udp.c
Expand Up @@ -340,7 +340,15 @@ static int uv__bind(uv_udp_t* handle,
goto out;
}

#ifdef SO_REUSEPORT /* Apple's version of SO_REUSEADDR... */
/* On the BSDs, SO_REUSEADDR lets you reuse an address that's in the TIME_WAIT
* state (i.e. was until recently tied to a socket) while SO_REUSEPORT lets
* multiple processes bind to the same address. Yes, it's something of a
* misnomer but then again, SO_REUSEADDR was already taken.
*
* None of the above applies to Linux: SO_REUSEADDR implies SO_REUSEPORT on
* Linux and hence it does not have SO_REUSEPORT at all.
*/
#ifdef SO_REUSEPORT
yes = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof yes) == -1) {
uv__set_sys_error(handle->loop, errno);
Expand Down

0 comments on commit 45d7bd8

Please sign in to comment.