This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to find out if socket closed?


On Fri, Jul 11, 2003 at 01:14:57PM -0500, Grant Edwards wrote:

> >> I've been browsing around the old network stack code for a
> >> couple hours now trying to figure out a way to determine if a
> >> TCP connection has been closed by the other end.
> > 
> > Off the top of my head: How about trying a zero sized read?
> 
> The problem is that there is receive data in the socket queue
> waiting to be read.  However, I don't have any room for the
> data, so if the socket hasn't been closed, I need to leave it
> there so that TCP/IP window-szie/flow-control kicks in and
> throttles the other end.
> 
> If the socket has been closed, I need to shut things down.

When the tcp input routine detects a FIN, it calls
socantrcvmore(), which sets the SS_CANTRCVMORE bit in
so->so_state.  

But I sure can't find any sort of system call which will tell
me if that flag is set.  I suppose I could add a custom option
to getsockopt(), but that sort of sucks for all the obvious
reasons.

-- 
Grant Edwards
grante@visi.com

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]