From e82900196f42bbcb28588f2ebb450d47f8e5900c Mon Sep 17 00:00:00 2001 From: Tijmen Verhoef Date: Mon, 16 May 2022 15:03:44 +0200 Subject: [PATCH] Minor bug fix: sock status check works on Windows --- src/RCONClient.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/RCONClient.cpp b/src/RCONClient.cpp index 298ae32..11bdd4b 100644 --- a/src/RCONClient.cpp +++ b/src/RCONClient.cpp @@ -5,6 +5,7 @@ #ifndef _WIN32 #include #endif + #include #include @@ -246,15 +247,22 @@ bool RCONClient::serverHasData() { #ifdef _WIN32 fd_set readFds; + FD_ZERO(&readFds); FD_SET(m_RCONServerSocket, &readFds); - if (select(m_RCONServerSocket + 1, &readFds, nullptr, nullptr, 0) != 0) + TIMEVAL timeout; + timeout.tv_sec = 0; + timeout.tv_usec = 0; + + int result = select(m_RCONServerSocket + 1, &readFds, nullptr, nullptr, &timeout); + + if (result < 0) { - Logger::Log(LogLevel::LEVEL_DEBUG, "Select on server sock failed\n"); + Logger::Log(LogLevel::LEVEL_DEBUG, "Error in select function: %d\n", result); return false; } - + return (FD_ISSET(m_RCONServerSocket, &readFds)) ? true : false; #else pollfd pollingfd;