Subject: RE: Detecting broken connection

RE: Detecting broken connection

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 12 Jul 2010 18:31:22 +0200 (CEST)

On Sun, 11 Jul 2010, Neil Gierman wrote:

> I had this same problem and the only way I was able to address it was to
> move to non-blocking sockets and run select to see of the socket is happy.
> Most of what I did was from the non blocking examples in the source code.

There's no need for non-blocking for that.

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.

Of course, TCP connections can just go "stalled" as well without being
possible to detect this easily.

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