多路复用select实现

select函数

  • int select(int nfds, fd_set *readfds,fd_set *writefds,fd_set *exceptfds, struct timeval *timeout);
  • nfds:是三个集合中编号最高的文件描述符,加上1
  • readfds/writefds/exceptfds:
    • 可读集合/可写集合/异常集合
  • timeout
    • NULL:永久阻塞
    • 0:非阻塞模式

poll函数

  • int poll (struct pollfd *fds,nfds_t, int timeout);

epoll API

  • epoll_create
  • epoll_wait
  • epoll_ctl

fd_set结构体

多路复用select实现_第1张图片

 

你可能感兴趣的:(服务器,运维)