diff --git a/mongoose.c b/mongoose.c index 53f58c69..66831830 100644 --- a/mongoose.c +++ b/mongoose.c @@ -2458,6 +2458,9 @@ struct mg_connection *mg_sntp_connect(struct mg_mgr *mgr, const char *url, #if MG_ENABLE_SOCKET #if defined(_WIN32) +#ifndef SO_EXCLUSIVEADDRUSE +#define SO_EXCLUSIVEADDRUSE ((int) (~SO_REUSEADDR)) +#endif #define MG_SOCK_ERRNO WSAGetLastError() #define FD(C_) ((SOCKET)(C_)->fd) #elif MG_ARCH == MG_ARCH_FREERTOS @@ -2654,6 +2657,7 @@ SOCKET mg_open_listener(const char *url) { // "Using SO_REUSEADDR and SO_EXCLUSIVEADDRUSE" !setsockopt(fd, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char *) &on, sizeof(on)) && + !setsockopt(fd, SOL_SOCKET, SO_BROADCAST, (char *) &on, sizeof(on)) && #endif bind(fd, &usa.sa, slen) == 0 && // NOTE(lsm): FreeRTOS uses backlog value as a connection limit diff --git a/mongoose.h b/mongoose.h index 18e541e7..8da88991 100644 --- a/mongoose.h +++ b/mongoose.h @@ -16,7 +16,7 @@ // license, as set out in . #pragma once -#define MG_VERSION "7.0" +#define MG_VERSION "7.1" #define MG_ARCH_CUSTOM 0 diff --git a/src/sock.c b/src/sock.c index 446c5b8c..c866ef0b 100644 --- a/src/sock.c +++ b/src/sock.c @@ -11,6 +11,9 @@ #if MG_ENABLE_SOCKET #if defined(_WIN32) +#ifndef SO_EXCLUSIVEADDRUSE +#define SO_EXCLUSIVEADDRUSE ((int) (~SO_REUSEADDR)) +#endif #define MG_SOCK_ERRNO WSAGetLastError() #define FD(C_) ((SOCKET)(C_)->fd) #elif MG_ARCH == MG_ARCH_FREERTOS @@ -207,6 +210,7 @@ SOCKET mg_open_listener(const char *url) { // "Using SO_REUSEADDR and SO_EXCLUSIVEADDRUSE" !setsockopt(fd, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char *) &on, sizeof(on)) && + !setsockopt(fd, SOL_SOCKET, SO_BROADCAST, (char *) &on, sizeof(on)) && #endif bind(fd, &usa.sa, slen) == 0 && // NOTE(lsm): FreeRTOS uses backlog value as a connection limit