tpsend(3)-routine for sending a message in a conversational connection
#include <atmi.h>
int tpsend(intcd, char *data, longlen, longflags, long *revent)
tpsend is used to send data across an open connection to another program. The caller must have control of the connection. tpsend's first argument, cd, specifies the open connection over which data is sent. cd is a descriptor returned from either tpconnect(3c) or the TPSVCINFO parameter passed to a conversational service.
The second argument, data, must point to a buffer previously allocated by tpalloc(3c). len specifies how much of the buffer to send. Note that if data points to a buffer of a type that does not require a length to be specified (for example, an FML fielded buffer), then len is ignored (and may be 0). Also, data can be NULL in which case len is ignored (no application data is sent - this might be done, for instance, to grant control of the connection without transmitting any data). The type and sub-type of data must match one of the types and sub-types recognized by the other end of the connection.
Following is a list of valid flags.
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(3c) calls).
TPNOBLOCK
TPNOBLOCK is not specified and a blocking condition exists, the caller blocks until the condition subsides or a timeout occurs (either transaction or blocking timeout).
TPNOTIME
TPSIGRSTRT
If an event exists for the descriptor, cd, then tpsend will fail without sending the caller's data. The event type is returned in revent. Valid events for tpsend are as follows:
TPEV_DISCONIMM
tpdiscon(3c), or it issued tpreturn(3c), tpcommit(3c) or tpabort(3c) with the connection still open. 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_SVCERR
tpreturn(3c) without having control of the conversation. In addition, tpreturn(3c) has been issued in a manner different from that described for TPEV_SVCFAIL below. This event can be caused by an ACL permissions violation; that is, the originator does not have permission to connect to the receiving process. This event is not returned at the time the tpconnect is issued, but is returned with the first tpsend (following a tpconnect with flag TPSENDONLY) or tprecv (following a tpconnect with flag TPRECVONLY). A system event and a log message are also generated.
TPEV_SVCFAIL
tpreturn(3c) without having control of the conversation. In addition, tpreturn(3c) was issued with the rval set to TPFAIL or TPEXIT and data to NULL.
Because each of these events indicates an immediate disconnection notification (that is, abortive rather than orderly), data in transit may be lost. The descriptor 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.
If the value of either SVCTIMEOUT in the ubbconfig file or TA_SVCTIMEOUT in the TM_MIB is non-zero, TPESVCERR is returned when a service timeout occurs.
Upon return from tpsend where revent is set to either TPEV_SVCSUCC or TPEV_SVCFAIL, the tpurcode global contains an application-defined value that was sent as part of tpreturn. The function tpsend returns -1 on error and sets tperrno to indicate the error condition. Also, if an event exists and no errors were encountered, tpsend returns -1 and tperrno is set to [TPEEVENT].
Under the following conditions, tpsend(3c) fails and sets tperrno to:
TPEINVAL]
data does not point to a buffer allocated by tpalloc(3c) or flags are invalid).
TPEBADDESC]
cd is invalid.
TPETIME]
TPNOBLOCK nor TPNOTIME was specified. In either case, no changes are made to *data, its contents nor *len. 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]
data is not sent when this error occurs. The event type is returned in revent.
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]
tpalloc(3c), tpconnect(3c), tpdiscon(3c), tprecv(3c), tpservice(3c)