lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Detection remote closed TCP connection


From: Jonathan Larmour
Subject: Re: [lwip-users] Detection remote closed TCP connection
Date: Wed, 28 May 2008 13:43:34 +0100
User-agent: Thunderbird 1.5.0.12 (X11/20070530)

Muhamad Ikhwan Ismail wrote:
> 
> while(1){
> int s = accept(); //blocks untill the connection is accepted
> 
> for(;;){
>        //runs IO
>     }
> }
> 
> I have a slight problem when the remote host closes the connection. I
> would want to include a connection status check and jump back
> to accept() if the connection is closed from the remote host. Is there
> anyway to do this ? It also has to be non-blocking and can be lwip specific.
> 
> So far I have heard few suggestions from the old thread :
> 
> 1. read/write 0 bytes. //blocks ?
> 2. Use of MSG_PEEK read (in 2003 was not yet implemented ).

Yes, if the connection is closed remotely you will read 0 bytes (as opposed
to no data available when you get the EWOULDBLOCK error). If you write to
it when closed you will get an error. If you are using select() in that
loop to process I/O, then the socket will be marked readable, and when you
read it you will get 0 bytes.

Jifl
-- 
eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["Si fractum non sit, noli id reficere"]------       Opinions==mine




reply via email to

[Prev in Thread] Current Thread [Next in Thread]