码迷,mamicode.com
首页 > 其他好文 > 详细

select() and pselect()

时间:2016-06-12 18:20:38      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:

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

  

  

select() and pselect()

标签:

原文地址:http://www.cnblogs.com/jason0401/p/5578109.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!