Commit 149a5538 authored by valenok's avatar valenok

not setting SO_REUSEADDR on windows

parent 236768b3
...@@ -1559,8 +1559,11 @@ static SOCKET mg_open_listening_port(struct mg_context *ctx, const char *str, ...@@ -1559,8 +1559,11 @@ static SOCKET mg_open_listening_port(struct mg_context *ctx, const char *str,
usa->u.sin.sin_port = htons((uint16_t) port); usa->u.sin.sin_port = htons((uint16_t) port);
if ((sock = socket(PF_INET, SOCK_STREAM, 6)) != INVALID_SOCKET && if ((sock = socket(PF_INET, SOCK_STREAM, 6)) != INVALID_SOCKET &&
#if !defined(_WIN32)
// On windows, SO_REUSEADDR is recommended only for broadcast UDP sockets
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
(char *) &on, sizeof(on)) == 0 && (char *) &on, sizeof(on)) == 0 &&
#endif // !_WIN32
bind(sock, &usa->u.sa, usa->len) == 0 && bind(sock, &usa->u.sa, usa->len) == 0 &&
listen(sock, 20) == 0) { listen(sock, 20) == 0) {
// Success // Success
......
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