|
Using Select for Data-driven Processing
- A process calls select to wait for one (or more) of
a collection of open files (or sockets) to be ready
for I/O.
int select(int n, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout);
FD_CLR(int fd, fd_set *set);
FD_ISSET(int fd, fd_set *set);
FD_SET(int fd, fd_set *set);
FD_ZERO(fd_set *set);
- select returns the number of fd's ready for I/O
- FD_ISSET is used to determine which fd's are ready
- select returns 0 if the timer expires
- select returns -1 if there is an error
|