1 #include <unistd.h> 2 #include <fcntl.h> 3 #include <errno.h> 4 #include "io_internal.h" 5 6 #ifdef __MINGW32__ 7 #include <winsock2.h> 8 #include <windows.h> 9 #include "windoze.h" 10 #endif 11 12 #ifndef O_NDELAY 13 #define O_NDELAY O_NONBLOCK 14 #endif 15 io_nonblock(int64 d)16void io_nonblock(int64 d) { 17 io_entry* e=iarray_get(&io_fds,d); 18 #ifdef __MINGW32__ 19 unsigned long i=1; 20 if (ioctlsocket( d, FIONBIO, &i)==0) 21 if (e) e->nonblock=1; 22 #else 23 if (fcntl(d,F_SETFL,fcntl(d,F_GETFL,0) | O_NDELAY)==0) 24 if (e) e->nonblock=1; 25 #endif 26 } 27