This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: network problems
On Fri, Apr 11, 2003 at 11:29:24PM +0100, Jonathan Larmour wrote:
> Andrew Lunn wrote:
> >>My problem is, I use select to wait for multiple inputs including
> >>the socket.
> >>Normally I recognize the a connection was closed by peer if read()
> >>returns 0 or I get an error while write().
> >>But sometimes I have the case, the I stop reading and writing to the
> >>socket
> >>for some reasons. So I just don't set the corresponding bit in the
> >>fdset.
> >>but in such state I can't recognize if the connection is closed.
> >
> >
> >Try setting the bit in exceptfds. I think select will then report when
> >the socket is closed.
>
> I'd be interested to know for other reasons if this is true! AFAIK
> exceptfds is only used for OOB data.
>
> BTW, did you really mean ferror() rather than
> getsockopt(...,SO_ERROR,...)?
----------------------------------------------------------------------
FERROR(3) Linux Programmer's Manual FERROR(3)
NAME
clearerr, feof, ferror, fileno - check and reset stream status
[Snip]
The function ferror tests the error indicator for the
stream pointed to by stream, returning non-zero if it is
set. The error indicator can only be reset by the clear
err function.
----------------------------------------------------------------------
A socket is a stream, so this should work.
> Although in either case I'm not entirely sure they'd ever get set
> unless some operation is done on the socket first.
Why should an operation been needed? When the socket is closed because
of a timeout or the peer, i would expect the local end to be closed
and -EPIPE or something similar set in the error indicator. I've not
tried this, so i could be totally wrong.
Andrew
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss