Subject: RE: Detecting broken connection

RE: Detecting broken connection

From: Neil Gierman <ngierman_at_roadrunn.com>
Date: Sun, 11 Jul 2010 21:06:34 -0500

> I keep a pool of connections open long-term. Recently I've been using
> them on wifi and realised that i don't handle broken sockets. What's
> the best way to do this so that I can resurrect stale sessions as
> needed? I want to test the connection somehow before issuing other
> 'commands' e.g. libssh2_sftp_open_ex. Currently these return some
> arbitrary failure (such as "Unable to send FXP_OPEN*" which I can't
> distinguish from other general errors making ti hard to know when to
> resurrect the session and when to report a failure.
>
> Any advice is very welcome :)
>

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.

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