ext/iodine/fio.c
/**
Sets a socket to non blocking state.

This function is called automatically for the new socket, when using
`fio_accept` or `fio_connect`.
*/
Sets a socket to non blocking state.
This function is called automatically for the new socket, when using
`fio_accept` or `fio_connect`.
Sets a socket to non blocking state . This function is called automatically for the new socket when using ` fio_accept ` or ` fio_connect ` .
int fio_set_non_block(int fd) {
#if defined(O_NONBLOCK)
  int flags;
  if (-1 == (flags = fcntl(fd, F_GETFL, 0)))
    flags = 0;
#ifdef O_CLOEXEC
  return fcntl(fd, F_SETFL, flags | O_NONBLOCK | O_CLOEXEC);
#else
  return fcntl(fd, F_SETFL, flags | O_NONBLOCK);
#endif
#elif defined(FIONBIO)
  static int flags = 1;
  return ioctl(fd, FIONBIO, &flags);
#else
#error No functions / argumnet macros for non-blocking sockets.
#endif
}
int fio_set_non_block ( int fd ) { #if defined ( O_NONBLOCK ) int flags ; if ( -1 == ( flags = fcntl ( fd , F_GETFL , 0 ) ) ) flags = 0 ; #ifdef O_CLOEXEC return fcntl ( fd , F_SETFL , flags | O_NONBLOCK | O_CLOEXEC ) ; #else return fcntl ( fd , F_SETFL , flags | O_NONBLOCK ) ; #endif #elif defined ( FIONBIO ) static int flags = 1 ; return ioctl ( fd , FIONBIO , & flags ) ; #else #error  No functions / argumnet macros for non-blocking sockets. #endif }
Sets a socket to non blocking state.
Sets a socket to non blocking state .
/* If they have O_NONBLOCK, use the Posix way to do it */ /* Fixme: O_NONBLOCK is defined but broken on SunOS 4.1.x and AIX 3.2.5. */ /* Otherwise, use the old way of doing it */