From 154479e849435f633dd781492bb6c6e44aec8a4c Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sun, 1 May 2022 15:07:51 +0200 Subject: [PATCH] [osdep] Restored changes. --- src/osdep/osdep.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/osdep/osdep.c b/src/osdep/osdep.c index 6d16a4a34..f18f98919 100644 --- a/src/osdep/osdep.c +++ b/src/osdep/osdep.c @@ -77,6 +77,13 @@ int set_nonblocking_fd(int fd) { +#ifdef WIN32 + /* on current mingw (202204) + * this is correct usage of winsock + * when compiling for win32 */ + u_long mode = 1; // set non-blocking socket + return ioctlsocket(fd, FIONBIO, &mode); +# else #if defined(O_NONBLOCK) || defined(O_NDELAY) int flags = fcntl(fd, F_GETFL, 0); @@ -94,6 +101,8 @@ set_nonblocking_fd(int fd) #else return 0; #endif + +#endif } /* Set a file descriptor to blocking mode. It returns a non-zero value on @@ -101,6 +110,13 @@ set_nonblocking_fd(int fd) int set_blocking_fd(int fd) { +#ifdef WIN32 + /* on current mingw (202204) + * this is correct usage of winsock + * when compiling for win32 */ + u_long mode = 0; // set blocking socket + return ioctlsocket(fd, FIONBIO, &mode); +# else #if defined(O_NONBLOCK) || defined(O_NDELAY) int flags = fcntl(fd, F_GETFL, 0); @@ -118,6 +134,7 @@ set_blocking_fd(int fd) #else return 0; #endif +#endif } void