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发生?
>当EPolLERR和EPolLHUP发生时,程序应该在事件处理函数中做什么?请详细解释其背后的原因.
提前致谢!
解决方法What makes EPolLERR and EPolLHUP happen?
男人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.
When EPolLERR and EPolLHUP happen,what should the program do in the
event handle function?
随着libevent通过事件EV_READ |在这种情况下,EV_WRITE,回调函数调用e. G. recv(),当对等体执行有序关闭(EPolLHUP)时可能返回0,如果发生错误则返回-1(EPolLERR);然后程序可能会清理连接,如果它是客户端,可能会重新建立连接.
总结以上是内存溢出为你收集整理的linux – 如何处理EPOLLERR和EPOLLHUP?全部内容,希望文章能够帮你解决linux – 如何处理EPOLLERR和EPOLLHUP?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)