I/O多路复用之poll
函数原型:
int poll(struct pollfd *fderray, unsigned long nfds, int timeout);
参数一:是指向一个结构数组
struct pollfd {
int fd; /* descriptor to check*/
short evevts; /*events of interest on fd*/
short revents; /* events that occurred on fd*/
}
events作为输入的常量:POLLIN(套接字可读) POLLOUT(套接字可写)等
revents用于检查fd是否满足我们events监听条件同select中的FD_ISSET();
参数二:nfds决定了我们参数的数组元素个数
参数三:poll函数返回前等待多长时间,三种情况:
0:立即返回,不阻塞
>0:等待指定数目的毫秒数
INFTIM:永远等待(INFTIM定义为一个负值)
poll用法类似于selct参考select

391

被折叠的 条评论
为什么被折叠?



