TPSEND-routine to send a message in a conversational connection
01TPSVCDEF-REC.
COPY TPSVCDEF.
01TPTYPE-REC.
COPY TPTYPE.
01DATA-REC.
COPY User data.
01TPSTATUS-REC.
COPY TPSTATUS.
CALL "TPSEND" USINGTPSVCDEF-RECTPTYPE-RECDATA-RECTPSTATUS-REC.
TPSEND is used to send data across an open connection to another program. The caller must have control of the connection. COMM-HANDLE specifies the open connection to send data over. COMM-HANDLE is a communications handle returned from either TPCONNECT() or TPSVCSTART().
DATA-REC contains the data to be sent and LEN specifies how much of the data to send. Note that if DATA-REC is a record of a type that does not require a length to be specified, then LEN is ignored (and may be 0). If REC-TYPE is SPACES, DATA-REC and LEN are ignored and a message is sent with no data (this might be done, for instance, to grant control of the connection without transmitting any data).
Following is a list of valid settings in TPSVCDEF-REC.
TPRECVONLY
TPSEND calls). When the receiver on the other end of the connection receives the data sent by TPSEND, it will also receive an event (TPEV-SENDONLY) indicating that it has control of the connection (and can not issue more any TPRECV() calls). Either TPRECVONLY or TPSENDONLY must be set.
TPSENDONLY
TPRECVONLY or TPSENDONLY must be set.
TPNOBLOCK
TPNOBLOCK or TPBLOCK must be set.
TPBLOCK
TPBLOCK is specified and a blocking condition exists, the caller blocks until the condition subsides or a timeout occurs (either transaction or blocking timeout). Either TPNOBLOCK or TPBLOCK must be set.
TPNOTIME
TPNOTIME or TPTIME must be set.
TPTIME
TPNOTIME or TPTIME must be set.
TPSIGRSTRT
TPNOSIGRSTRT or TPSIGRSTRT must be set.
TPNOSIGRSTRT
TPNOSIGRSTRT or TPSIGRSTRT must be set.
If an event exists for COMM-HANDLE, then TPSEND will return without sending the caller's data. The event type is returned in TPEVENT. Valid events for TPSEND are as follows.
TPEV-DISCONIMM
TPDISCON(), or the originator of the connection issued TPRETURN() with open subordinate connections. This event is also returned to the originator or subordinate when a connection is broken due to a communications error (for example, a server, machine, or network failure).
TPEV-SVCFAIL
TPRETURN() without having control of the conversation. In addition. TPRETURN() was issued with TPFAIL set and no data record (that is, the REC-TYPE passed to TPRETURN() was set to SPACES)
TPEV-SVCERR
TPRETURN() without having control of the conversation. In addition, TPRETURN() was issued in a manner different from that described for TPEV-SVCFAIL below.
Because each of these events indicates an immediate disconnection notification (that is, abortive rather than orderly), data in transit may be lost. The communications handle used for the connection is no longer valid. If the two programs were participating in the same transaction, then the transaction has been marked abort-only.
Upon successful completion, TPSEND sets TP-STATUS to [TPOK]. If an event exists and no errors were encountered, TPSEND sets TP-STATUS to [TPEEVENT]. When TP-STATUS is set to [TPEEVENT] and TP-EVENT is either TPEV-SVCSUCC or TPEV-SVCFAIL, APPL-RETURN-CODE contains an application-defined value that was sent as part of TPRETURN.
Under the following conditions, TPSEND fails and sets TP-STATUS to (unless otherwise noted, failure does not affect caller's transaction, if one exits):
TPEINVAL]
TPEBADDESC]
COMM-HANDLE contains an invalid communications handle.
TPETIME]
TPNOBLOCK nor TPNOTIME were specified. In either case, neither DATA-REC nor TPTYPE-REC are changed. If a transaction timeout occurred, then any attempts to send or receive messages on any connections or to start a new connection will fail with [TPETIME] until the transaction has been aborted.
TPEEVENT]
TPEVENT. DATA-REC is not sent when this error occurs.
TPEBLOCK]
TPNOBLOCK was specified.
TPGOTSIG]
TPSIGRSTRT was not specified.
TPEPROTO]
TPSEND was called in an improper context (for example, the connection was established such that the calling program can only receive data).
TPESYSTEM]
TPEOS]
TPCONNECT(), TPDISCON(), TPRECV()