Tuesday, June 28, 2005

Usages of select

Select system call prototype -
int select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);

where
Four macros are provided to manipulate the sets.
FD_ZERO will clear a set.
FD_SET and FD_CLR add or remove a given descriptor from a set.
FD_ISSET tests to see if a descriptor is part of the set;

" n is the highest-numbered descriptor in any of the three sets, plus 1."
timeout is an upper bound on the amount of time elapsed before select returns. It may be zero, causing select to return immediately. (This is useful for polling.)
If timeout is NULL (no timeout), select can block indefinitely.

So always try to use "n" as (highest_fd+1) -> it will definately improve performance as seen by us on OpenVMS

0 Comments:

Post a Comment

<< Home