TreeviewCopyright © aleen42 all right reserved, powered by aleen42

Poll Back

  • poll()select()實現的功能相似, 能監聽多個文件描述符. poll()能監聽特定的某個文件描述符其返回事件
  • poll()select()更具有細緻的分類
  • poll()效率要比select()
method
/* select */
unsigned int poll(struct pollfd* __fds, nfds_t __nfds, int __timeout)

/* pollfd */
struct pollfd
{
    int fd;
    short int events;    //expected events     
    short int revents;    //return events
}
parameters
  • pollfd: 設置監聽的文件描述符和期待的事件
  • nfds: 文件描述符的個數
  • timeout: 指定測試時間閾值上界
    • NULL: forever
    • >0: time
    • 0: return immediately after check, without waiting
return value
  • num: the number of ready descriptors
  • 0: timeout but none is ready
  • -1: failure
  • errno: wrong code
Empty Comments
Sign in GitHub

As the plugin is integrated with a code management system like GitLab or GitHub, you may have to auth with your account before leaving comments around this article.

Notice: This plugin has used Cookie to store your token with an expiration.