BEA Logo BEA Tuxedo Release 7.1

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

 

   Tuxedo Doc Home   |   Programming   |   Topic List   |   Previous   |   Next   |   Contents

   Programming a BEA Tuxedo Application Using COBOL

Sending and Receiving Messages

Once the BEA Tuxedo system establishes a conversational connection, communication between the initiator and subordinate is accomplished using send and receive calls. The process with control of the connection can send messages using the TPSEND(3cbl) routine; the process without control can receive messages using the TPRECV(3cbl) routine.

Note: Initially, the originator (that is, the client) decides which process has control using the TPSENDONLY or TPRECVONLY flag value of the TPCONNECT call. TPSENDONLY specifies that control is being retained by the originator; TPRECVONLY, that control is being passed to the called service.

Sending Messages

To send a message, use the TPSEND(3cbl) routine with the following signature.

01 TPSVCDEF-REC.
COPY TPSVCDEF.

01 TPTYPE-REC.
COPY TPTYPE.

01 DATA-REC.
COPY User Data.

01 TPSTATUS-REC.
COPY TPSTATUS.

CALL "TPSEND" USING TPSVCDEF-REC TPTYPE-REC USER-DATA-REC TPSTATUS-REC.

Refer to Defining a Service for more information on the TPSVCDEF-REC record, and refer to Defining Typed Records for more information on the TPTYPE-REC record.

In the event of a failure, the TPSEND routine sets TP-STATUS to the appropriate error condition. For a list of possible error codes, refer to TPSEND(3cbl) in the BEA Tuxedo COBOL Function Reference.

You are not required to pass control each time you issue the TPSEND routine. In some applications, the process authorized to issue TPSEND calls can execute as many calls as required by the current task before turning over control to the other process. In other applications, however, the logic of the program may require the same process to maintain control of the connection throughout the life of the conversation.

The following example shows how to invoke the TPSEND routine.

Sending Data in Conversational Mode


   . . .
SET TPNOBLOCK TO TRUE.
SET TPNOTIME TO TRUE.
SET TPSIGRSTRT TO TRUE.
SET TPRECVONLY TO TRUE.
*
CALL "TPSEND" USING TPSVCDEF-REC
TPTYPE-REC
DATA-REC
TPSTATUS-REC.
IF NOT TPOK
error processing . . .


Receiving Messages

To receive data sent over an open connection, use the TPRECV(3cbl) routine with the following signature.

01 TPSVCDEF-REC.
COPY TPSVCDEF.

01 TPTYPE-REC.
COPY TPTYPE.

01 DATA-REC.
COPY User Data.

01 TPSTATUS-REC.
COPY TPSTATUS.

CALL "TPRECV" USING TPSVCDEF-REC TPTYPE-REC DATA-REC TPSTATUS-REC.

Refer to Defining a Service for more information on the TPSVCDEF-REC record. Refer to Defining Typed Records for more information on the TPTYPE-REC record.

The following example shows how to use the TPRECV routine.

Receiving Data in Conversation


  . . .
SET TPNOCHANGE TO TRUE.
SET TPBLOCK TO TRUE.
SET TPNOTIME TO TRUE.
SET TPSIGRSTRT TO TRUE.
*
MOVE LENGTH OF DATA-REC TO LEN.
*
CALL "TPRECV" USING TPSVCDEF-REC
TPTYPE-REC
DATA-REC
TPSTATUS-REC.
IF NOT TPOK
error processing . . .