How to tell if server connection has timed out.
Ivan Smahin
ivan_smahin at paradigmasoft.com
Thu Mar 24 01:57:37 CDT 2011
On 3/24/2011 3:49 AM, Chris Jones wrote:
> What is the best way using the C++ api to tell that the server has
> timed out a user, ie they have been idle for longer than the time out
> period? I've tried get_IsConnected() but it returns a false
> positive. What I'm trying to do is detect the disconnect and attempt
> to reconnect.
get_IsConnected() return false in two cases:
1. Connection is closed.
2. Communication error (exception on sending/receiving kTestConnection
command) which leads to closing this connection.
You may get the last error from the connection.
Something like this:
...
VConnection* pConn;
....
if( pConn->get_IsConnected() == false )
{
// Not connected anymore. Probably because of vServer time out.
const String& lastErrorMsg = pConn->get_ErrorDescription();
// Show user lastErrorMsg
...
// Reconnect procedure
...
}
--
Best regards,
Ivan Smahin
Senior Software Engineer
Paradigma Software, Inc
Valentina - The Ultra-Fast Database
http://www.valentina-db.com
More information about the Valentina
mailing list