Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

accept(2)

connect(2)

getitimer(2)

read(2)

write(2)

recv(2)

send(2)

SELECT(2)

NAME

select − synchronous I/O multiplexing

USAGE

#include <sys/time.h>
 
nfound = select(nfds, readfds, writefds, execptfds, timeout) int nfound, nfds, *readfds, *writefds, *execptfds; struct timeval *timeout;

DESCRIPTION

Select examines the I/O descriptors specified by the bit masks readfds, writefds, and execptfds to see if they are ready for reading, writing, or if they have an exception condition pending, respectively.  The bit “1<<f” in the mask represents the file descriptor f. Nfds descriptors are checked, i.e., the function examines the bits from zero through nfds-1 in the masks. Select returns, in place, a mask of those descriptors that are ready.  The total number of ready descriptors is returned in nfound.

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, select blocks indefinitely.  To poll all of the I/O descriptors without waiting, the timeout argument should be non-zero, and should point to a zero-valued timeval structure. 

Any of readfds, writefds, and execptfds may be set to zero where these descriptors are not of interest. 

NOTES

The descriptor masks are always modified on return, even if the call returns as the result of the time-out. 

RETURN VALUE

Select returns the number of descriptors that are contained in the bit masks, or −1 if an error occurred.  If the time limit expires, then select returns zero. 

ERRORS

An error return from select indicates:

[EBADF] One of the bit masks specified an invalid descriptor. 

[EINTR] A signal was delivered before any of the selected events occurred or the time limit expired. 

RELATED INFORMATION

accept(2), connect(2), getitimer(2), read(2), write(2), recv(2), send(2)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026