- 论坛徽章:
- 0
|
请问那位高手用过poll()这个函数
写select差不多
但是可以指定对每个描述字等待的信号
以下转向ZDNET
http://www00.zdnet.com.cn:88/developer/code/story/0,2000081534,39030918,00.htm
poll()说明
poll()方法试图合并select()函数的参数,同时提供范围更广的事件通知。SUSv2 如下定义poll() 函数:
int poll(structpollfdfds[ ], nfds_tnfds, int timeout);
参数含义如下:
structpollfdfds[ ] - pollfd结构数组
nfds_tnfds - fds[ ]中文件描述符集合的数目
int timeout - poll()等待事件发生的时间长度(单位是毫秒)
返回值表示多少fds有事件发生。
pollfd结构通常包括以下结构成员:
intfd – 表示某个事件由哪个fd监视
short events – 表示哪些事件将被监视的位字段
short revents – 表示调用poll()时检测到的事件的比特位 |
|