标签:
NAME
select, pselect, FD_ZERO, FD_SET, FD_ISSET - Synchronous I/O Multiplexing.
SYNOPSIS
/*according to earlier standards*/
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set * exceptfds, strcut timeval *timeout);
vodi FD_CLR(int fd, fd_set *set);
void FD_SET(int fd, fd_set *set);
void FD_ZERO(fd_set *set);
int FD_ISSET(int fd, fd_set *set);
#include <sys/select.h>
int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set * exceptfds, strcut timeval *timeout, const sigset_t *sigmask);
DESCRIPTION
select() and pselect() allow a program to monitor multiple file descriptors, waiting until one or more of the file descriptors become ready for some class of I/O operation(e.g., input possible).
nfds is the highest-numbered file descriptor in any of the three sets, plus 1.
Three independent sets of file descriptors are watched.
the timeout argument specifies the interval that select() should block waiting for a file descriptor to become ready.
Four macros are provided to manipulate the sets. FD_ZERO() clears a set. FD_SET() and FD_CLR() respectively add and remove a given file descriptor from a set. FD_ISSET() tests to see if a file descriptor is part of the set; this is useful after select() returns.
RETURN VALUE
On success, select() and pselect() return the number of file descriptors contained in the three returned descriptor sets(that is, the total number of bits that are set in readfds, writefds, exceptfds).
标签:
原文地址:http://www.cnblogs.com/jason0401/p/5578109.html