FreeBSD/contrib/ntp/libntp/socket.c
/*
 * make_socket_nonblocking() - set up descriptor to be non blocking
 */
set up descriptor to be non blocking
set up descriptor to be non blocking
void
make_socket_nonblocking(
	SOCKET fd
	)
{
#ifdef USE_FIONBIO
#undef O_NONBLOCK
#undef FNDELAY
#undef O_NDELAY
#endif
#if defined(O_NONBLOCK) 
	if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) {
		msyslog(LOG_ERR,
			"fcntl(O_NONBLOCK) fails on fd #%d: %m", fd);
		exit(1);
	}
#elif defined(FNDELAY)
	if (fcntl(fd, F_SETFL, FNDELAY) < 0) {
		msyslog(LOG_ERR, "fcntl(FNDELAY) fails on fd #%d: %m",
			fd);
		exit(1);
	}
#elif defined(O_NDELAY) 
	if (fcntl(fd, F_SETFL, O_NDELAY) < 0) {
		msyslog(LOG_ERR, "fcntl(O_NDELAY) fails on fd #%d: %m",
			fd);
		exit(1);
	}
#elif defined(FIONBIO)
	{
		int on = 1;
		if (ioctl(fd, FIONBIO, &on) < 0) {
			msyslog(LOG_ERR,
				"ioctl(FIONBIO) fails on fd #%d: %m",
				fd);
			exit(1);
		}
	}
#elif defined(FIOSNBIO)
	if (ioctl(fd, FIOSNBIO, &on) < 0) {
		msyslog(LOG_ERR,
			"ioctl(FIOSNBIO) fails on fd #%d: %m", fd);
		exit(1);
	}
#else
# include "Bletch: Need non-blocking I/O!"
#endif
}
void make_socket_nonblocking ( SOCKET fd ) { #ifdef USE_FIONBIO #undef  O_NONBLOCK #undef  FNDELAY #undef  O_NDELAY #endif #if defined ( O_NONBLOCK ) if ( fcntl ( fd , F_SETFL , O_NONBLOCK ) < 0 ) { msyslog ( LOG_ERR , " " , fd ) ; exit ( 1 ) ; } #elif defined ( FNDELAY ) if ( fcntl ( fd , F_SETFL , FNDELAY ) < 0 ) { msyslog ( LOG_ERR , " " , fd ) ; exit ( 1 ) ; } #elif defined ( O_NDELAY ) if ( fcntl ( fd , F_SETFL , O_NDELAY ) < 0 ) { msyslog ( LOG_ERR , " " , fd ) ; exit ( 1 ) ; } #elif defined ( FIONBIO ) { int on = 1 ; if ( ioctl ( fd , FIONBIO , & on ) < 0 ) { msyslog ( LOG_ERR , " " , fd ) ; exit ( 1 ) ; } } #elif defined ( FIOSNBIO ) if ( ioctl ( fd , FIOSNBIO , & on ) < 0 ) { msyslog ( LOG_ERR , " " , fd ) ; exit ( 1 ) ; } #else # include " " #endif }
make_socket_nonblocking() - set up descriptor to be non blocking
make_socket_nonblocking () - set up descriptor to be non blocking
/*
	 * set non-blocking,
	 */ /* in vxWorks we use FIONBIO, but the others are defined for old
	 * systems, so all hell breaks loose if we leave them defined
	 */ /* POSIX */ /* generally the same as FNDELAY */