Commit 203688a3 authored by Sergey Lyubka's avatar Sergey Lyubka

Added comment for Win32 SO_RESUSEADDR

parent 29f4703e
...@@ -548,6 +548,12 @@ static sock_t ns_open_listening_socket(union socket_address *sa) { ...@@ -548,6 +548,12 @@ static sock_t ns_open_listening_socket(union socket_address *sa) {
if ((sock = socket(sa->sa.sa_family, SOCK_STREAM, 6)) != INVALID_SOCKET && if ((sock = socket(sa->sa.sa_family, SOCK_STREAM, 6)) != INVALID_SOCKET &&
#ifndef _WIN32 #ifndef _WIN32
// SO_RESUSEADDR is not enabled on Windows because the semantics of
// SO_REUSEADDR on UNIX and Windows is different. On Windows,
// SO_REUSEADDR allows to bind a socket to a port without error even if
// the port is already open by another program. This is not the behavior
// SO_REUSEADDR was designed for, and leads to hard-to-track failure
// scenarios. Therefore, SO_REUSEADDR was disabled on Windows.
!setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &on, sizeof(on)) && !setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &on, sizeof(on)) &&
#endif #endif
!bind(sock, &sa->sa, sa->sa.sa_family == AF_INET ? !bind(sock, &sa->sa, sa->sa.sa_family == AF_INET ?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment