Help!

How EPOLLHUP event is received on a socket fd

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> App Development RSS
Next:  running out of /tmp space  
Author Message
saurabhth
External


Since: Aug 12, 2009
Posts: 2



PostPosted: Wed Aug 12, 2009 3:56 am    Post subject: How EPOLLHUP event is received on a socket fd
Archived from groups: comp>os>linux>development>apps (more info?)

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.
Back to top
Loïc_Domaigné
External


Since: Jul 28, 2009
Posts: 4



PostPosted: Wed Aug 12, 2009 4:50 am    Post subject: Re: How EPOLLHUP event is received on a socket fd [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.

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
Back to top
saurabhth
External


Since: Aug 12, 2009
Posts: 2



PostPosted: Wed Aug 12, 2009 9:59 pm    Post subject: Re: How EPOLLHUP event is received on a socket fd [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Aug 12, 4:50 pm, Loïc Domaigné <loic.domai....TakeThisOut@googlemail.com>
wrote:
> 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.
>
> 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

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
Back to top
Loïc_Domaigné
External


Since: Jul 28, 2009
Posts: 4



PostPosted: Thu Aug 13, 2009 11:50 am    Post subject: Re: How EPOLLHUP event is received on a socket fd [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.
>
> > 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
>
> 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.

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.
--
My Blog: http://www.domaigne.com/blog

"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
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> App Development All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum