Skip to content

Commit

Permalink
Minor bug fix: sock status check works on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nemjit001 committed May 16, 2022
1 parent 9664ca6 commit e829001
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/RCONClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef _WIN32
#include <poll.h>
#endif

#include <cstring>
#include <assert.h>

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e829001

Please sign in to comment.