All rights reserved. The Berkeley software License Agreement
specifies the terms and conditions for redistribution.
@(#)select.2 6.3 (Berkeley) 02/03/86
#include <sys/types.h> #include <sys/time.h>nfound = select(nfds, readfds, writefds, exceptfds, timeout) int nfound, nfds; fd_set *readfds, *writefds, *exceptfds; struct timeval *timeout;
int fd; fd_set fdset; FD_SET(fd, &fdset) FD_CLR(fd, &fdset) FD_ISSET(fd, &fdset) FD_ZERO(&fdset)
Some macros are provided for manipulating descriptor sets. "FD_ZERO(&fdset)" initializes a descriptor set fdset to the null set. "FD_SET(fd, &fdset)" includes a particular descriptor fd in fdset . "FD_CLR(fd, &fdset)" removes fd from fdset . "FD_ISSET(fd, &fdset)" is nonzero if fd is a member of fdset , zero otherwise. The behavior of these macros is undefined if a descriptor value is less than zero or greater than or equal to FD_SETSIZE , which is normally at least equal to the maximum number of descriptors supported by the system.
If timeout is a non-zero pointer, it specifies a maximum interval to wait for the selection to complete. If timeout is a zero pointer, the select blocks indefinitely. To affect a poll, the timeout argument should be non-zero, pointing to a zero valued timeval structure.
Any of readfds , writefds , and exceptfds may be given as zero pointers if no descriptors are of interest.
15 [EBADF] One of the descriptor sets specified an invalid descriptor.
15 [EINTR] A signal was delivered before the time limit expired and before any of the selected events occurred.
15 [EINVAL] The specified time limit is invalid. One of its components is negative or too large.