diff options
Diffstat (limited to 'libvncclient/sockets.c')
-rw-r--r-- | libvncclient/sockets.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libvncclient/sockets.c b/libvncclient/sockets.c index 0171a5c..28b0256 100644 --- a/libvncclient/sockets.c +++ b/libvncclient/sockets.c @@ -551,14 +551,17 @@ AcceptTcpConnection(int listenSock) rfbBool SetNonBlocking(int sock) { -#ifndef __MINGW32__ - if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) { - rfbClientErr("AcceptTcpConnection: fcntl\n"); - return FALSE; - } +#ifdef WIN32 + unsigned long block=1; + if(ioctlsocket(sock, FIONBIO, &block) == SOCKET_ERROR) { + errno=WSAGetLastError(); #else - rfbClientErr("O_NONBLOCK on MinGW32 NOT IMPLEMENTED\n"); + int flags = fcntl(sock, F_GETFL); + if(flags < 0 || fcntl(sock, F_SETFL, flags | O_NONBLOCK) < 0) { #endif + rfbClientErr("Setting socket to non-blocking failed: %s\n",strerror(errno)); + return FALSE; + } return TRUE; } |