This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: network problems
On Donnerstag, 10. April 2003 12:56, Andrew Lunn wrote:
> > Another question, does anybody know if there is an ioctl() or similar for
> > checking if a TCP connaction is still alive?
>
> Guessing here... But if the connection is dead, the socket should be
> no longer valid. Thus ferror(3) should return something useful. If it
> does not return an error, assume the connection is still alive.
>
> Have you set the keepalive option. If you don't have this option set
> and there is no traffic, the stack will not notice the connection is
> dead until the next time you try to send something. With keepalive
> set, it sends ACK messages every so often so it can detect dead
> connections.
>
> Andrew
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.
Roland
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss