- 论坛徽章:
- 0
|
因为文件描述符从0开始计算的,但是从1开始使用,所有要+1.
- fd_set rset;
- FD_ZERO(&rset); /* initialize the set: all bits off */
- FD_SET(1, &rset); /* turn on bit for fd 1 */
- FD_SET(4, &rset); /* turn on bit for fd 4 */
- FD_SET(5, &rset); /* turn on bit for fd 5 */
复制代码 For example, given the code that turns on the indicators for descriptors 1, 4, and 5, the maxfdp1 value is 6. The reason it is 6 and not 5 is that we are specifying the number of descriptors, not the largest value, and descriptors start at 0.
-------摘自unpv1 |
|