Go to the previous, next section.

select

SYNOPSIS

int select(int numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);

Macro utilities:

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);

PARAMETERS

numfds: [in] the number of file descriptors to watch.

readfds: [in out] on entry, the file descriptor to watch for readability. On exit, the file descriptors that are readable.

writefds: [in out] on entry, the file descriptors to watch for writability. On exit, the file descriptors that are writable.

exceptfds: [in out] on entry, the file descriptor to watch exceptions. On exit, the file descriptors have exceptions raised.

timeout: [in out] on entry, the timeout value. On return, contains the remaining time.

DESCRIPTION

Makes the calling task sleep until some conditions on the file descriptors become true or until a timeout value expires. There are three conditions for which files may be tested:

Whenever one of the conditions on one the specified files is true, the call returns.

There are four utilities provided for manipulation of the file descriptor sets:

FD_SET
sets the specified file descriptor flag.

FD_CLR
clears the specified file descriptor flag.

FD_ZERO
clears the set.

FD_ISSET
returns true if the file descriptor flag is set.

RETURN VALUE

On success, returns zero. On error, returns -1 and sets errno to one of the following value:

Go to the previous, next section.