SELECT(2X) — Unix Programmer’s Manual
NAME
select − synchronous i/o multiplexing
SYNOPSIS
nfd = select(nfds, readfds, writefds, milli);
int nfds;
int ∗readfds, ∗writefds;
int milli;
DESCRIPTION
Select examines the i/o descriptors specified by the bit masks readfds and writefds to see if they are ready for reading and/or writing respectively and returns, in place, a mask of those descriptors which are ready. The total number of ready descriptors is returned in nfd.
Milli is the maximum number of milliseconds to wait before giving up if no descriptors come active. If no maximum wait is desired a very large integer can be given.
A milli of 0 specifies a poll; the select returns whatever information is available without blocking. Either readfds or writefds may be given as 0 if no descriptors are interesting.
For the present, since UNIX allows only 20 file descriptors it suffices for nfd to be 20, and for readfds and writefds to be pointers to integer variables. File descriptor f is represented by the bit “1<<f” in the mask.
SEE ALSO
ioctl(2x), read(2), write(2), send(2x), receive(2x), accept(2x), connect(2x)
BUGS
The system currently rounds milli to integral seconds, with a resolution of +/− 1 second.
This call is provisional, and will exist in a slightly different form in 4.2bsd.
7th Edition — 3/17/82