mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Set SO_EXCLUSIVEADDRUSE for server sockets on Windows. (#44)
On Windows, the shutdown() call relies on exclusively owning the server socket.
This commit is contained in:
@@ -99,8 +99,13 @@ int TCPAcceptor::start() {
|
||||
}
|
||||
address.sin_port = htons(m_port);
|
||||
|
||||
#ifdef _WIN32
|
||||
int optval = 1;
|
||||
setsockopt(m_lsd, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char*)&optval, sizeof optval);
|
||||
#else
|
||||
int optval = 1;
|
||||
setsockopt(m_lsd, SOL_SOCKET, SO_REUSEADDR, (char*)&optval, sizeof optval);
|
||||
#endif
|
||||
|
||||
int result = bind(m_lsd, (struct sockaddr*)&address, sizeof(address));
|
||||
if (result != 0) {
|
||||
|
||||
Reference in New Issue
Block a user