Subject: Re: Detecting broken connection

Re: Detecting broken connection

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 14 Jul 2010 17:32:54 +0200 (CEST)

On Wed, 14 Jul 2010, Alexander Lamaison wrote:

>> If you _know_ the sockets should be silent (ie there's no TCP traffic on
>> them) you can select() to see if they've become readable, and if they are
>> in spite of you knowing they shouldn't be, reading 0 bytes from them
>> indicates they're disconnected.
>
> Do I need to actually do the read?

Not necessarily no. If you are sure they should be idle, you can skip the
reading.

> What would a >0 return value indicate?

That data came over the connection anyway!

> Presumably that I'd gotten my logic wrong and the socket wasn't meant to be
> silent

Exactly!

-- 
  / daniel.haxx.se
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-07-14