From 3b09685b42c04110161d212261f16431273d5b94 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Tue, 19 Jun 2012 22:36:54 +0000 Subject: [PATCH] - Have NET_Sleep work with Windows' INVALID_SOCKET again... - Use SOCKET_ERROR in NET_Sleep. --- code/qcommon/net_ip.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/code/qcommon/net_ip.c b/code/qcommon/net_ip.c index fb76206a..1c3a2c76 100644 --- a/code/qcommon/net_ip.c +++ b/code/qcommon/net_ip.c @@ -1632,7 +1632,7 @@ void NET_Event(fd_set *fdr) // com_dropsim->value percent of incoming packets get dropped. if(rand() < (int) (((double) RAND_MAX) / 100.0 * (double) net_dropsim->value)) continue; // drop this packet - } + } if(com_sv_running->integer) Com_RunAndTimeServerPacket(&from, &netmsg); @@ -1672,14 +1672,11 @@ void NET_Sleep(int msec) if(ip6_socket != INVALID_SOCKET) { FD_SET(ip6_socket, &fdr); - - if(ip6_socket > highestfd) + + if(highestfd == INVALID_SOCKET || ip6_socket > highestfd) highestfd = ip6_socket; } - timeout.tv_sec = msec/1000; - timeout.tv_usec = (msec%1000)*1000; - #ifdef _WIN32 if(highestfd == INVALID_SOCKET) { @@ -1689,9 +1686,12 @@ void NET_Sleep(int msec) } #endif + timeout.tv_sec = msec/1000; + timeout.tv_usec = (msec%1000)*1000; + retval = select(highestfd + 1, &fdr, NULL, NULL, &timeout); - - if(retval < 0) + + if(retval == SOCKET_ERROR) Com_Printf("Warning: select() syscall failed: %s\n", NET_ErrorString()); else if(retval > 0) NET_Event(&fdr);