网络编程入门04

One loop per thread

#include <poll.h>
  int poll(struct pollfd fd[], nfds_t nfds, int timeout);

    参数:

   1)第一个参数:一个结构数组,struct pollfd结构如下:

  struct pollfd{

  int fd;              //文件描述符

  short events;    //请求的事件

  short revents;   //返回的事件

  };
        2)第二个参数nfds:要监视的描述符的数目。
       3)最后一个参数timeout:是一个用毫秒表示的时间,是指定poll在返回前没有接收事件时应该等待的时间。如果  它的值为-1,poll就永远都不会超时。如果整数值为32个比特,那么最大的超时周期大约是30分钟。

猜你喜欢

转载自www.cnblogs.com/aiqingyi/p/11252110.html