From e9bd7bd7ca7b5f5ce396b99dc8756c2d2b490556 Mon Sep 17 00:00:00 2001 From: Christian Beier Date: Sun, 4 Aug 2024 11:50:00 +0200 Subject: [PATCH] common/sockets: fix logic error in WIN32 sock_set_nonblocking() impl According to https://learn.microsoft.com/en-us/windows/win32/winsock/winsock-ioctls "The lpvInBuffer parameter points at an unsigned long (QoS), which is nonzero if non-blocking mode is to be enabled and zero if it is to be disabled." Closes #613 --- src/common/sockets.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/sockets.c b/src/common/sockets.c index de66fa768..4fe3634cd 100644 --- a/src/common/sockets.c +++ b/src/common/sockets.c @@ -32,8 +32,8 @@ rfbBool sock_set_nonblocking(rfbSocket sock, rfbBool non_blocking, void (*log)(const char *format, ...)) { #ifdef WIN32 - unsigned long block = non_blocking ? 0 : 1; - if(ioctlsocket(sock, FIONBIO, &block) == SOCKET_ERROR) { + unsigned long non_blocking_ulong = non_blocking; + if(ioctlsocket(sock, FIONBIO, &non_blocking_ulong) == SOCKET_ERROR) { errno=WSAGetLastError(); #else int flags = fcntl(sock, F_GETFL);