tpconnect-routine for establishing a conversational service connection
#include <atmi.h>
int tpconnect(char *svc, char *data, long len, long flags)
tpconnect() allows a program to set up a half-duplex connection to a conversational service, svc. The name must be one of the conversational service names posted by a conversational server.
As part of setting up a connection, the caller can pass application defined data to the listening program. If the caller chooses to pass data, then data must point to a buffer previously allocated by tpalloc(3). 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 passed to the conversational service). The type and sub-type of data must match one of the types and sub-types recognized by svc. data and len are passed to the conversational service via the TPSVCINFO structure with which the service is invoked; the service does not have to call tprecv(3) to get the data.
Following is a list of valid flags.
TPNOTRAN
svc is invoked, it is not performed on behalf of the caller's transaction. Note that svc may still be invoked in transaction mode but it will not be the same transaction: a svc may have as a configuration attribute that it is automatically invoked in transaction mode. A caller in transaction mode that sets this flag is still subject to the transaction timeout (and no other). If a service fails that was invoked with this flag, the caller's transaction is not affected.
TPSENDONLY
TPSENDONLY or TPRECVONLY must be specified.
TPRECVONLY
TPSENDONLY or TPRECVONLY must be specified.
TPNOBLOCK
tpconnect(); the function may block waiting for an acknowledgement from the server. When TPNOBLOCK is not specified and a blocking condition exists, the caller blocks until the condition subsides or a blocking timeout or transaction timeout occurs.
TPNOTIME
TPSIGRSTRT
Upon successful completion, tpconnect() returns a descriptor that is used to refer to the connection in subsequent calls. Otherwise it returns \-1 and sets tperrno to indicate the error condition.
Under the following conditions, tpconnect() fails and sets tperrno to an error code listed below. (Unless otherwise noted, failure does not affect the caller's transaction, if one exists)
TPEINVAL]
svc is NULL, data is non-NULL and does not point to a buffer allocated by tpalloc(3), TPSENDONLY or TPRECVONLY was not specified in flags, or flags are otherwise invalid).
TPENOENT]
svc because it does not exist or is not a conversational service.
TPEITYPE]
data is not one of the allowed types and subtypes that svc accepts.
TPELIMIT]
TPETRAN]
svc belongs to a program that does not support transactions and TPNOTRAN was not set.
TPETIME]
TPNOBLOCK nor TPNOTIME were specified. 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.
TPEBLOCK]
TPNOBLOCK was specified.
TPGOTSIG]
TPSIGRSTRT was not specified.
TPEPROTO]
tpconnect() was called in an improper context.
TPESYSTEM]
TPEOS]
tpalloc(3), tpdiscon(3), tprecv(3), tpsend(3), tpservice(3)