Sends a request to the server.
%INCLUDE CTPUBLIC;
DCL 01 COMMAND FIXED BIN(31) INIT(0); 01 RETCODE FIXED BIN(31) INIT(0); CALL CTBSEND (COMMAND, RETCODE);
(I) Handle for this client/server operation. This handle is defined in the associated CTBCMDALLOC call.
(O) Variable where the result from an executed function returns. Its value is one of the codes listed under “Returns,” in this section.
CTBSEND returns one of the following values:
Value |
Meaning |
---|---|
CS_SUCCEED (-1) |
The routine completed successfully. |
CS_FAIL (-2) |
The routine failed. This result can indicate that SNA sessions will not come up. |
CS_CANCELLED (-202) |
The routine was cancelled.
|
This code fragment demonstrates the use of CTBSEND. It is taken from the sample program SYCTSAR4 in Appendix B, “Sample RPC Application.”
/*------------------------------------------------------------------*/ /* */ /* Subroutine to allocate, send, and process commands */ /* */ /*------------------------------------------------------------------*/ SEND_PARAM: PROC ;
/*------------------------------------------------------------*/ /* allocate a command handle */ /*------------------------------------------------------------*/ CALL CTBCMDAL( CSL_CON_HANDLE, CSL_RC, CSL_CMD_HANDLE ) ; IF CSL_RC ^= CS_SUCCEED THEN DO ; NO_ERRORS_SW = FALSE ; MSGSTR = 'CTBCMDALLOC failed' ; CALL ERROR_OUT; CALL ALL_DONE ; END ; /*------------------------------------------------------------*/ /* prepare the command (an RPC request) */ /*------------------------------------------------------------*/ PF_STRLEN = STG(CF_CMD); CALL CTBCOMMA( CSL_CMD_HANDLE, CSL_RC, CS_RPC_CMD, CF_CMD, PF_STRLEN, CS_UNUSED ); IF CSL_RC ^= CS_SUCCEED THEN DO ; NO_ERRORS_SW = FALSE ; MSGSTR = 'CTBCOMMAND failed' ; CALL ERROR_OUT; CALL ALL_DONE ; END ;
/*------------------------------------------------------------*/ /* */ /* setup a return parameter for NUM_OF_ROWS */ /* */ /* describe the first parameter (NUM_OF_ROWS) */ /* */ /*------------------------------------------------------------*/ DF_NAME = '@parm1'; DF_NAMELEN = 6; DF_DATATYPE = CS_INT_TYPE; DF_FORMAT = CS_FMT_UNUSED; DF_MAXLENGTH = CS_UNUSED; DF_STATUS = CS_RETURN; DF_USERTYPE = CS_UNUSED; PM_LEN = STG(PM_PARAM1); PM_PARAM1 = 0; /* NUM_OF_ROWS */ PM_NULLIND = 0; CALL CTBPARAM( CSL_CMD_HANDLE, CSL_RC, DATAFMT, PM_PARAM1, PM_LEN, PM_NULLIND ); IF CSL_RC ^= CS_SUCCEED THEN DO ; NO_ERRORS_SW = FALSE ; MSGSTR = 'CTBPARAM CS_INT_TYPE parm1 failed' ; CALL ERROR_OUT; CALL ALL_DONE ; END ; /*------------------------------------------------------------*/ /* */ /* describe the second parameter (DEPTNO) */ /* */ /*------------------------------------------------------------*/ DF_NAME = '@parm2'; DF_NAMELEN = 6; DF_DATATYPE = CS_VARCHAR_TYPE; DF_FORMAT = CS_FMT_UNUSED; DF_MAXLENGTH = CS_UNUSED; DF_STATUS = CS_INPUTVALUE; DF_USERTYPE = CS_UNUSED; PM_PARAM2 = PF_DEPT; /* DEPTNO */ PM_LEN = PF_DEPT_SIZE ; PM_NULLIND = 0; CALL CTBPARAM( CSL_CMD_HANDLE, CSL_RC, DATAFMT, PM_PARAM2, PM_LEN, PM_NULLIND ); IF CSL_RC ^= CS_SUCCEED THEN DO ; NO_ERRORS_SW = FALSE ; MSGSTR = 'CTBPARAM CS_VARCHAR_TYPE parm2 failed' ; CALL ERROR_OUT; CALL ALL_DONE ; END ; /*------------------------------------------------------------*/ /* send the command */ /*------------------------------------------------------------*/ CALL CTBSEND( CSL_CMD_HANDLE, CSL_RC ) ; IF CSL_RC ^= CS_SUCCEED THEN DO ; MSGSTR = 'CTBSEND failed' ; NO_ERRORS_SW = FALSE ; CALL ERROR_OUT; CALL ALL_DONE ; END ; END SEND_PARAM ;
The following code fragment demonstrates the use of CTBSEND. It is taken from the sample program SYCTSAA4 in Appendix A, “Sample Language Application.”
/*------------------------------------------------------------------*/ /* */ /* Subroutine to allocate, send, and process commands */ /* */ /*------------------------------------------------------------------*/ SEND_COMMAND: PROC ; /*------------------------------------------------------------*/ /* find out what the maximum number of connections is */ /*------------------------------------------------------------*/ CALL CTBCONFI( CSL_CTX_HANDLE, CSL_RC, CS_GET, CS_MAX_CONNECT, CF_MAXCONNECT, STG(CF_MAXCONNECT), CS_FALSE, CF_OUTLEN ) ; IF CSL_RC ^= CS_SUCCEED THEN DO ; MSGSTR = 'CTBCONFIG failed' ; NO_ERRORS_SW = FALSE ; CALL ERROR_OUT; CALL ALL_DONE ; END ; /*------------------------------------------------------------*/ /* display number of connections */ /*------------------------------------------------------------*/ OR2_MAXCONNECT = CF_MAXCONNECT; /*------------------------------------------------------------*/ /* allocate a command handle */ /*------------------------------------------------------------*/ CALL CTBCMDAL( CSL_CON_HANDLE, CSL_RC, CSL_CMD_HANDLE ) ; IF CSL_RC ^= CS_SUCCEED THEN DO ; MSGSTR = 'CTBCMDALLOC failed' ; NO_ERRORS_SW = FALSE ; CALL ERROR_OUT; CALL ALL_DONE ; END ; /*------------------------------------------------------------*/ /* prepare the language request */ /*------------------------------------------------------------*/ PF_STRLEN = STG(CF_LANG2 ) ; CALL CTBCOMMA( CSL_CMD_HANDLE, CSL_RC, CS_LANG_CMD, CF_LANG2, PF_STRLEN, CS_UNUSED ) ; IF CSL_RC ^= CS_SUCCEED THEN DO ; MSGSTR = 'CTBCOMMAND failed' ; NO_ERRORS_SW = FALSE ; CALL ERROR_OUT; CALL ALL_DONE ; END ; /*------------------------------------------------------------*/ /* send the language request */ /*------------------------------------------------------------*/ CALL CTBSEND( CSL_CMD_HANDLE, CSL_RC ) ; IF CSL_RC ^= CS_SUCCEED THEN DO ; MSGSTR = 'CTBSEND failed' ; NO_ERRORS_SW = FALSE ; CALL ERROR_OUT; CALL ALL_DONE ; END ; END SEND_COMMAND ;
CTBSEND signals the end of the data to be sent to a server (no more parameters, data, messages) and sends a request to the server.
Sending a request to a server is a three-step process. To send a request to a server, an application:
Initiates the request by calling CTBCOMMAND, which initiates a language request, RPC, or message stream to send to the server.
Describes parameters for the request, using CTBPARAM.
Not all requests require parameters. For example, a remote procedure call may or may not require parameters, depending on the stored procedure or transaction being called.
Calls CTBSEND to send the request stream to the server.
CTBSEND does not wait for a response from the server. An application must call CTBRESULTS to verify the success of the request and to set up the results for processing.
Related functions: