diff --git a/src/stream/StreamNetwork.cpp b/src/stream/StreamNetwork.cpp index 5aa2660d..03817554 100644 --- a/src/stream/StreamNetwork.cpp +++ b/src/stream/StreamNetwork.cpp @@ -107,9 +107,14 @@ namespace OpenLogReplicator { throw RuntimeException(10061, "network error, errno: " + std::to_string(errno) + ", message: " + strerror(errno) + " (6)"); constexpr int64_t opt = 1; - if (setsockopt(serverFD, SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT, &opt, sizeof(opt)) != 0) + if (setsockopt(serverFD, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) != 0) throw RuntimeException(10061, "network error, errno: " + std::to_string(errno) + ", message: " + strerror(errno) + " (7)"); +#ifdef SO_REUSEPORT + if (setsockopt(serverFD, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt)) != 0) + throw RuntimeException(10061, "network error, errno: " + std::to_string(errno) + ", message: " + strerror(errno) + " (21)"); +#endif + if (bind(serverFD, res->ai_addr, res->ai_addrlen) < 0) throw RuntimeException(10061, "network error, errno: " + std::to_string(errno) + ", message: " + strerror(errno) + " (8)"); if (listen(serverFD, 1) < 0)