Chinaunix首页 | 论坛 | 博客
  • 博客访问: 67176
  • 博文数量: 18
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 160
  • 用 户 组: 普通用户
  • 注册时间: 2015-05-20 19:05
文章分类
文章存档

2016年(3)

2015年(15)

我的朋友

分类: LINUX

2016-04-12 10:14:14

 函数原型 int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);

引用解释:
根据POSIX标准,
The nfds argument specifies the range of descriptors to be tested. The first nfds descriptors shall be checked in each set; that is, the descriptors from zero through nfds-1 in the descriptor sets shall be examined.

个人理解:
系统内部用bitmask描述fd set,fd number 从0开始,fd = x 的句柄描述符在 bit mask中的位置是第x+1,所以select需要monitor前x+1个句柄对应的device,所以ndfs = x+1
阅读(2899) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~