From f4eff6558dea2d396e51ac01c267a40b16be1518 Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Tue, 22 Aug 2023 23:08:57 +0100 Subject: [PATCH] Fix for compilation on Windows (lack of per-call non-blocking semantics) --- Src/nwclient.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Src/nwclient.c b/Src/nwclient.c index 699461b0..f5dbc265 100644 --- a/Src/nwclient.c +++ b/Src/nwclient.c @@ -33,6 +33,7 @@ // https://stackoverflow.com/a/14388707/995351 #define SO_REUSEPORT SO_REUSEADDR #define MSG_NOSIGNAL 0 + #define MSG_DONTWAIT 0 #endif #ifdef OSX @@ -252,6 +253,12 @@ static void *_listenTask( void *arg ) client->portNo = newsockfd; client->rp = h->wp; +#ifdef WIN32 + /* Set port nonblocking since it can't be done per-call in Windows */ + u_long iMode=1; + ioctlsocket(newsockfd,FIONBIO,&iMode); +#endif + if ( pthread_mutex_init( &client->dataAvailable_m, NULL ) != 0 ) { genericsExit( -1, "Failed to establish mutex for condition variable" EOL );