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

Commit

Permalink
unix: turn on SO_REUSEPORT for UDP sockets
Browse files Browse the repository at this point in the history
Required on BSD-like systems for local UDP multicast. Without it, the bind()
call fails with EADDRINUSE.
  • Loading branch information
bnoordhuis committed Jan 26, 2012
1 parent b88bc43 commit 9c76d0d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/unix/udp.c
Expand Up @@ -340,6 +340,14 @@ static int uv__bind(uv_udp_t* handle,
goto out;
}

#ifdef SO_REUSEPORT /* Apple's version of SO_REUSEADDR... */
yes = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof yes) == -1) {
uv__set_sys_error(handle->loop, errno);
goto out;
}
#endif

if (flags & UV_UDP_IPV6ONLY) {
#ifdef IPV6_V6ONLY
yes = 1;
Expand Down

0 comments on commit 9c76d0d

Please sign in to comment.