From b1160cfb2e73ada541361a80232ee9eaa2331a54 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 9 Feb 2023 14:04:42 +0100 Subject: [PATCH] fixing setsockopt for windows --- src/fsfw/osal/common/TcpTmTcServer.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/fsfw/osal/common/TcpTmTcServer.cpp b/src/fsfw/osal/common/TcpTmTcServer.cpp index 6743a7f81..55c2d4926 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.cpp +++ b/src/fsfw/osal/common/TcpTmTcServer.cpp @@ -92,12 +92,22 @@ ReturnValue_t TcpTmTcServer::initialize() { } if (tcpConfig.reuseAddr) { +#ifdef PLATFORM_WIN + DWORD enable = 1; + setsockopt(listenerTcpSocket, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast(&enable), + sizeof(enable)); +#elif defined(PLATFORM_UNIX) unsigned int enable = 1; setsockopt(listenerTcpSocket, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)); +#endif } + if (tcpConfig.reusePort) { +// Not supported in windows +#ifdef PLATFORM_UNIX unsigned int enable = 1; setsockopt(listenerTcpSocket, SOL_SOCKET, SO_REUSEPORT, &enable, sizeof(enable)); +#endif } // Bind to the address found by getaddrinfo