Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How EPOLLHUP event is received on a socket fd

1,903 views
Skip to first unread message

saurabhth

unread,
Aug 12, 2009, 6:56:59 AM8/12/09
to
Hi,

I have developed a simple server that uses epoll_wait with TCP
sockets. The server program listens to incoming connections on
listening socket and on acceptiong incoming connections adds them to
the pollset to be waited upon by epoll_wait.

I would like to know how can I produce a condition by which the event
EPOLLHUP is generated and returned by epoll_wait for a socket fd ?

Pls guide.

Loïc Domaigné

unread,
Aug 12, 2009, 7:50:53 AM8/12/09
to
Hi,

my guess would be that EPOLLHUP is the "epoll" version of POLLHUP...
for TCP socket, this means that the socket is half-closed as result of
a shutdown().

HTH,
Loïc
--
My Blog: http://www.domaigne.com/blog

"One of the main causes of the fall of the Roman Empire was that–
lacking zero–they had no way to indicate successful termination of
their C programs." -- Robert Firth

saurabhth

unread,
Aug 13, 2009, 12:59:21 AM8/13/09
to
On Aug 12, 4:50 pm, Loïc Domaigné <loic.domai...@googlemail.com>
wrote:

Hi Loic,

I tried simulating the behaviour by writing a client program that
connects to the server and after the connection has been made, half
closes the connection with shutdown(SHUT_WR).

The server still receives the EPOLLIN event, no EPOLLHUP event is
received.

Kindly help

Loïc Domaigné

unread,
Aug 13, 2009, 2:50:58 PM8/13/09
to
Hi,

From the experiments I made (using poll, not epoll), I found out that
you get a POLLHUP only after receiving a RST segment. This means that
the client has closed the socket (e.g. due to a crash), and the server
has performed one write on the closed socket.

HTH,
Loïc.

"The first 90% of the code accounts for the first 90% of the
development time. The remaining 10% of the code accounts for the other
90% of the development time." -- Tom Cargill

0 new messages