mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-16 10:39:49 +00:00
Better reuseaddr handling on Win32
This commit is contained in:
1 parent
83c106a857
commit
6c93446a1f
3 files changed
+9
-1
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user