On Wed, 2008-05-28 at 13:43 +0100, Jonathan Larmour wrote:
> 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.
Although if the remote end has closed gracefully, using a FIN rather
than a RST, you'll get no error when writing to the socket as the
connection is still open in that direction.
Kieran
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users