CTBCONNECT

Description

Connects to a server.

Syntax

COPY CTPUBLIC.
01 CONNECTION              PIC S9(9) COMP SYNC.
01 RETCODE                 PIC S9(9) COMP SYNC.
01 SERVERNAME              PIC X(30). 
01 SERVERNAME-LEN          PIC S9(9) COMP SYNC.
01 BUFBLANKSTRIP           PIC S9(9) COMP SYNC.
CALL 'CTBCONNE' USING 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 “Return value,” 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.

TDS-INVALID-NAMELENGTH

The length specified for the server name is invalid.

TDS-EXCEED-MAX-CONN (-39)

The maximum number of connections is already open.

TDS-ROUTE-NOT-AVAILABLE (-34)

All paths are in use; no more paths are available.

TDS-ROUTE-NOT-FOUND (-33)

No such route is defined to the Connection Router.

TDS-NOT-INITIALIZED (-32)

The Connection Router has not initialized.

TDS-SERVER-NOT-FOUND (-30)

The specified server name could not be found in the Name Server.

TDS-WRONG-STATE (-6)

Program is in the wrong communication state to issue this call.

Examples

Example 1

The following code fragment demonstrates the use of CTBCONNECT. It is taken from the sample program SYCTSAA5 in Appendix A, “Sample Language Requests.”

	 *************************
	 * CONNECT TO THE SERVER *
	 *************************
	CALL 'CTBCONNE' USING CSL-CON-HANDLE
                                  CSL-RC
                                  PF-SERVER
                                  PF-SERVER-SIZE
                                  CS-FALSE.
            IF CSL-RC NOT EQUAL CS-SUCCEED
              THEN
                 MOVE SPACES TO MSGSTR
                 STRING 'CTBCONNE failed' DELIMITED BY SIZE INTO MSGSTR
                 PERFORM PRINT-MSG
                 PERFORM ALL-DONE
            END-IF.
            IF NO-ERRORS
              THEN
                PERFORM SEND-COMMAND
            END-IF.

Usage

See also

Related functions

Related topics