为什么select使用时第一个参数要加1

来源:互联网 发布:易语言图片压缩源码 编辑:程序博客网 时间:2024/04/28 07:55
Select的函数格式
int select(int maxfdp,fd_set *readfds,fd_set *writefds,fd_set *errorfds,struct timeval *timeout);

int maxfdp是一个整数值,是指集合中所有文件描述符的范围,即所有文件描述符的最大值加1,不能错!在Windows中这个参数的值无所谓,可以设置不正确。

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

nfds  is the highest-numbered file descriptor in any of the three sets,  plus 1.
原创粉丝点击