diff --git a/src/unix/udp.c b/src/unix/udp.c index 91f7d1a2..349bfae3 100644 --- a/src/unix/udp.c +++ b/src/unix/udp.c @@ -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);