首页 > 其他 > 详细

《UNIX网络编程》之select IO

时间:2014-10-16 18:52:34      阅读:263      评论:0      收藏:0      [点我收藏+]

select 函数的原理

select 管理者

用select来管理多个IO

一旦其中的一个或者多个IO检测到我们所感兴趣的事件,

select 函数返回,返回值为检测到的事件个数

然后,遍历事件,进而去处理这些事件。

 

select 原型:

/* According to POSIX.1-2001 */
       #include <sys/select.h>

       /* According to earlier standards */
       #include <sys/time.h>
       #include <sys/types.h>
       #include <unistd.h>

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

       void FD_CLR(int fd, fd_set *set);//移除
       int  FD_ISSET(int fd, fd_set *set);//是否存在
       void FD_SET(int fd, fd_set *set);//
       void FD_ZERO(fd_set *set);//清空集合

参数:

1. 读、写、异常集合中的文件描述符的最大值加1

2. 读集合 输入输出参数

3. 写集合 输入输出参数

4. 异常集合 输入输出参数

5. 超时时间 输入输出参数

 

《UNIX网络编程》之select IO

原文:http://www.cnblogs.com/wiessharling/p/4029275.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!