Select – Comtrol eCos User Manual
Page 569
Chapter 38. TCP/IP Library Reference
SEE ALSO
poll(2), select(2), sysconf(3)
HISTORY
A poll() system call appeared in AT&T System V UNIX.
BSD
December 13, 1994
BSD
select
SELECT(2)
System Calls Manual
SELECT(2)
NAME
select - synchronous I/O multiplexing
SYNOPSIS
#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);
FD_SET(fd, &fdset);
FD_CLR(fd, &fdset);
FD_ISSET(fd, &fdset);
FD_ZERO(&fdset);
DESCRIPTION
select() examines the I/O descriptor sets whose addresses are passed in
readfds, writefds, and exceptfds to see if some of their descriptors are
ready for reading, are ready for writing, or have an exceptional condi-
tion pending, respectively.
The first nfds descriptors are checked in
each set; i.e., the descriptors from 0 through nfds-1 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.
select() returns the total number of ready descrip-
tors in all the sets.
The descriptor sets are stored as bit fields in arrays of integers.
The
following macros are provided for manipulating such 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 non-
zero 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 max-
465