CTBCONNECT

Description

Connects to a server.

Syntax

%INCLUDE CTPUBLIC;
DCL
     01 CONNECTION            FIXED BIN(31) INIT(0);
     01 RETCODE                  FIXED BIN(31) INIT(0);
     01 SERVERNAMECHAR(10) INIT(‘yourserver ’)
     01 SERVERNAME_LEN   FIXED BIN(31);
     01 BUFBLANKSTRIP       FIXED BIN(31);
 
CALL CTBCONNE (CONNECTION, RETCODE, SERVERNAME, SERVERNAME_LEN, BUFBLANKSTRIP);

Parameters

CONNECTION

(I) Handle for this connection. This connection handle must already be allocated with CTBCONALLOC. The connection handle corresponds to the TDPROC handle in the Open ServerConnect Gateway-Library.

RETCODE

(O) Variable where the result from an executed function returns. Its value is one of the codes listed under “Returns,” in this section.

SERVERNAME

(I) Name of the connected server. For clients running SNA, this is the name by which the server is known to the Open ClientConnect Server Path Definition Table. For clients running TCP/IP without a gateway, this is the actual name of the Adaptive Server in the LAN interfaces file.

You must assign a value to this argument. If a server name is not specified, CTBCONNECT fails.

SERVERNAME_LEN

(I) Length, in bytes, of SERVERNAME. If the server name ends at the last non-blank character, assign CS_TRUE to BUFBLANKSTRIP.

BUFBLANKSTRIP

(I) Blank stripping indicator. Indicates whether trailing blanks are stripped.

Assign this argument one of the following symbolic values:

Value

Meaning

CS_TRUE (1)

Trailing blanks are stripped. The value in the buffer ends at the last non-blank character.

CS_FALSE (0)

Trailing blanks are not stripped. They are included in the value.

Returns

CTBCONNECT returns one of the following values listed in Table 3-8.

Table 3-8: CTBCONNECT return values

Value

Meaning

CS_SUCCEED (-1)

The routine completed successfully.

CS_FAIL (-2)

The routine failed.

TDS_CRTABLE_UNAVAILABLE (-31)

The Connection Router table cannot be loaded.

Examples

Example 1

The following code fragment demonstrates how to use CTBCONNECT. It is taken from the sample program SYCTSAA4 in Appendix A, “Sample Language Application.”

/*------------------------------------------------------------*/
/* open connection to the server or CICS region               */
/*------------------------------------------------------------*/
 
         CALL CTBCONNE( CSL_CON_HANDLE,
                        CSL_RC,
                        PF_SERVER,
                        PF_SERVER_SIZE,
                        CS_FALSE ) ;
 
         IF CSL_RC ^= CS_SUCCEED THEN
         DO ;
           MSGSTR = 'CTBCONNECT failed' ;
           NO_ERRORS_SW = FALSE ;
           CALL ERROR_OUT;
           CALL ALL_DONE ;
         END ;

 /*------------------------------------------------------------*/
 /* invokes SEND_COMMAND routine                               */
 /*------------------------------------------------------------*/
         IF NO_ERRORS_SW
           THEN
             CALL SEND_COMMAND ;

Usage

See also

Related functions:

Related topics: