Questions on epoll_wait()
Hi Folks,
Based on online tutorials and examples for epoll, EPOLLIN - indicate available data. EPOLLHUP - indicates a remote connection close. Now in the below mentioned scenario, what would be the behavior of epoll_wait? (1) epoll_wait returns for FD_X with EPOLLIN. (2) In a while loop, I start reading the data. (3) At the same time while I am executing read(Step 2), if remote end closes the connection for FD_X, Would I get a separate EPOLLHUP event, if I go back to wait on epoll_wait()? How do I detect this otherwise? Based on written examples, I get an EIO error on read, if the remote end has closed the connection. Is it possible to differenitate between an EIO error that occurs due to (1) A remote connection close. (2) Legitimate error in read. Thanks for the help. -Alphonse |
Quote:
to get more accurate error distinction, you can also set the EPOLLRDHUP flag using epoll_ctl(). When epoll_wait() returns, check for EPOLLRDHUP (peer disconnected), EPOLLHUP (unexpected close of socket), EPOLLERR (fd error condition), EPOLLIN (data available). In the last case (only EPOLLIN set), invoke read(). If read() returns -1, check errno for specifics. If read() returns 0, this would be quite a surprise. Do you have a test program available to play with? Kind regards dmdeb |
All times are GMT -5. The time now is 11:56 PM. |