Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

Client TCP/IP Connect and Communication Timeout Options

The c-tree client library now supports a timeout on TCP/IP socket send and receive operations. The timeout is configured on a per-connection basis and is disabled by default. To set a socket timeout, after connecting to the FairCom Server, set the c-tree connection-specific global variable ctsocktimeout to the desired timeout value in seconds. If a TCP/IP send or receive operation blocks for more than the specified number of seconds, the c-tree client returns a fatal communication error ARQS_ERR (127) or ARSP_ERR (128). This timeout value can be changed at any time, and takes effect on the next socket call.

To facilitate detection of this condition, two new error codes have been introduced and are returned when a socket operation times out:

Symbolic Error Code

Error Code

Explanation

TRQS_ERR

808

Request timed out.

TRSP_ERR

809

Response timed out.

When using this feature the application must consider cases in which it is appropriate to increase or disable this timeout. For example, if the application makes any c-tree calls that are expected to take awhile, such as record read calls that block attempting to acquire a lock, or calls to rebuild large data files.

Additionally, an optional timeout on c-tree TCP/IP connect operations was added. To use this feature, after calling RegisterCtree() and before calling InitISAMXtd(), a client application sets the same c-tree connection-specific global variable as above, ctsocktimeout to a positive value, which indicates the number of seconds after which the connect operation times out. If the operation times out, the c-tree function returns c-tree error ASKY_ERR (133).

Note: This value remains in effect for all future calls. You should change this value as needed for operations that may be expected to take longer (or shorter) to complete, for example, a large batch call.

FairCom DB ISAM Example


#include <ctgvar.h>

REGCTREE("my c-tree instance");


/* set the connection timeout to 1 minute */

ctsocktimeout = 60;

INTISAMX( ... );

c-treeDB C API Example


#include <ctgvar.h>

CTHANDLE hSession = ctdbAllocSession(CTSESSION_CTDB);


/* set the connection timeout to 1 minute */

ctsocktimeout = 60;

ctdbLogon(hSession, ... );

c-treeDB C++ API Example


#include <ctgvar.h>

CTSession hSession(CTSESSION_CTDB);


/* set the connection timeout to 1 minute */

ctsocktimeout = 60;

hSession.Logon( ... );

ctsocktimeout is also used to set the timeout on TCP/IP send and receive operations. If the only timeout that is desired is on the connect operation, the client application should reset ctsocktimeout to zero after InitISAMXtd() returns.

FairCom DB ISAM Example


INTISAMX( ... );


/* clear the send and receive timeout */

ctsocktimeout = 0;

c-treeDB C API Example

CTHANDLE hSession = ctdbAllocSession(CTSESSION_CTDB);

ctdbLogon(hSession, ... );

/* clear the send and receive timeout */

ctsocktimeout = 0;

c-treeDB C++ API Example


CTSession hSession(CTSESSION_CTDB);

hSession.Logon( ... );


// clear the send and receive timeout

ctsocktimeout = 0;

TOCIndex