Skip to content

Commit

Permalink
net: Set SO_REUSEADDR for Windows too
Browse files Browse the repository at this point in the history
When running the rpc tests in Wine, nodes often fail to listen on localhost
due to a stale socket from a previous run. This aligns the behavior with other
platforms.
  • Loading branch information
theuni authored and schinzelh committed Jan 16, 2016
1 parent 372dd39 commit a6b8f02
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1550,8 +1550,10 @@ bool BindListenPort(const CService &addrBind, string& strError, bool fWhiteliste
setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int));
#endif
// Allow binding if the port is still in TIME_WAIT state after
// the program was closed and restarted. Not an issue on windows!
// the program was closed and restarted.
setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (void*)&nOne, sizeof(int));
#else
setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (const char*)&nOne, sizeof(int));
#endif

// Set to non-blocking, incoming connections will also inherit this
Expand Down

0 comments on commit a6b8f02

Please sign in to comment.