From b5483b9d776d35d3c27b2c8cc2cc225090006604 Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Sat, 7 May 2016 21:43:49 +0300 Subject: [PATCH] Set SO_REUSEPORT only if it's defined. --- socket.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/socket.c b/socket.c index c545a09..2e31b10 100644 --- a/socket.c +++ b/socket.c @@ -51,8 +51,10 @@ bool cSatipSocket::Open(const int portP, const bool reuseP) ERROR_IF_FUNC(setsockopt(socketDescM, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0, "setsockopt(SO_REUSEADDR)", Close(), return false); yes = reuseP; +#ifdef SO_REUSEPORT ERROR_IF_FUNC(setsockopt(socketDescM, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes)) < 0 && errno != ENOPROTOOPT, "setsockopt(SO_REUSEPORT)", Close(), return false); +#endif // Bind socket memset(&sockAddrM, 0, sizeof(sockAddrM)); sockAddrM.sin_family = AF_INET;