NAME | SYNOPSIS | API RESTRICTIONS | FEATURES | DESCRIPTION | RETURN VALUES | ATTRIBUTES | SEE ALSO | LIMITATIONS
#include <sys/types.h> #include <sys/time.h> #include <unistd.h>int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
The function or functions documented here may not be used safely in all application contexts with all APIs provided in the ChorusOS 5.0 product.
See API(5FEA) for details.
POSIX_SOCKETS
The select system call examines the I/O descriptor sets whose addresses are passed in readfds, writefds, and exceptfds to verify whether any of their descriptors are ready for reading, writing, or have an exceptional condition pending, respectively. The first nfds descriptors are checked in each set; in other words, the descriptors from 0 to nfds-1 inclusive in the descriptor sets are examined. On return, select replaces the given descriptor sets with subsets consisting of those descriptors that are ready for the requested operation.
The descriptor sets are stored as bit fields in arrays of integers. The following macros are provided for manipulating the descriptor sets:
Initializes a descriptor set fdset to the null set.
Includes a particular descriptor fd in fdset.
Removes fd from 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 not the NULL pointer, it specifies a maximum interval to wait for the selection to complete. If timeout is the NULL pointer, the select blocks indefinitely. To affect a poll, the timeout argument should be non NULL, pointing to a zero-valued timeval structure.
The readfds, writefds, and exceptfds parameters may be given as NULL pointers if no descriptors are required.
The select system call returns the number of ready descriptors contained in the descriptor sets. If the time limit expires select returns 0. If select returns with an error, including one due to an interrupted call, the descriptor sets will be unmodified.
An error return from select indicates:
One of the descriptor sets specified an invalid descriptor.
One of the fd_set arguments, or the delay are invalid pointers.
The calling thread has been aborted before the time limit expired and before any of the events selected occurred.
The time limit specified is invalid. One of its components is negative or too large.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
MT-level |
MT-safe |
It is possible that the timeout value will be modified by the select system call.
NAME | SYNOPSIS | API RESTRICTIONS | FEATURES | DESCRIPTION | RETURN VALUES | ATTRIBUTES | SEE ALSO | LIMITATIONS