linux – 如何处理EPOLLERR和EPOLLHUP?
我在libevent epoll中阅读了代码,这里是代码:
if (what & (EPOLLHUP|EPOLLERR)) { ev = EV_READ | EV_WRITE; } else { if (what & EPOLLIN) ev |= EV_READ; if (what & EPOLLOUT) ev |= EV_WRITE; if (what & EPOLLRDHUP) ev |= EV_CLOSED; } 据我所知,当EPOLLERR或EPOLLHUP发生时,应该关闭连接.但是在上面的代码中,当EPOLLHUP | EPOLLERR遇到时,事件掩码被设置为EV_READ | EV_WRITE.所以我的问题是: >是什么让EPOLLERR和EPOLLHUP发生? 提前致谢! 解决方法
男人epoll_ctl EPOLLERR Error condition happened on the associated file descriptor. epoll_wait(2) will always wait for this event; it is not necessary to set it in events. EPOLLHUP Hang up happened on the associated file descriptor. epoll_wait(2) will always wait for this event; it is not necessary to set it in events.
随着libevent通过事件EV_READ |在这种情况下,EV_WRITE,回调函数调用e. G. recv(),当对等体执行有序关闭(EPOLLHUP)时可能返回0,如果发生错误则返回-1(EPOLLERR);然后程序可能会清理连接,如果它是客户端,可能会重新建立连接. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |