Set SO_REUSEADDR on network sockets.

This commit is contained in:
Egor Vorontsov
2025-12-16 06:24:30 +03:00
parent c509698b54
commit 56b75aaffc
2 changed files with 10 additions and 0 deletions

View File

@@ -288,6 +288,11 @@ void NetworkServer::StartServer()
return;
}
/*---------------------------------------------------------*\
| Set socket options - reuse addr |
\*---------------------------------------------------------*/
setsockopt(server_sock[socket_count], SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));
/*---------------------------------------------------------*\
| Bind the server socket |
\*---------------------------------------------------------*/

View File

@@ -267,6 +267,11 @@ bool net_port::tcp_server(const char * port)
myAddress.sin_addr.s_addr = inet_addr("0.0.0.0");
myAddress.sin_port = htons(atoi(port));
/*-------------------------------------------------*\
| Set socket options - reuse addr |
\*-------------------------------------------------*/
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));
/*-------------------------------------------------*\
| Bind the server socket |
\*-------------------------------------------------*/