t_connect Subroutine for Transport Layer Interface

Purpose

Establishes a connection with another transport user.

Library

Transport Layer Interface Library (libtli.a)

Syntax

#include <tiuser.h>

int t_connect(fd, sndcall, rcvcall)
int  fd;
struct t_call * sndcall;
struct t_call * rcvcall;

Description

The t_connect subroutine enables a transport user to request a connection to the specified destination transport user.

Parameters

Item Description
fd Identifies the local transport end point where communication will be established.
sndcall Specifies information needed by the transport provider to establish a connection.
rcvcall Specifies information associated with the newly established connection.

The sndcall and rcvcall parameters point to a t_call structure that contains the following members:

struct netbuf addr;
struct netbuf opt;
struct netbuf udata;
int sequence;

The netbuf structure is described in the tiuser.h file. In the sndcall parameter, the addr field specifies the protocol address of the destination transport user, the opt field presents any protocol-specific information that might be needed by the transport provider, the udata field points to optional user data that may be passed to the destination transport user during connection establishment, and the sequence field has no meaning for this function.

On return to the rcvcall parameter, the addr field returns the protocol address associated with the responding transport end point, the opt field presents any protocol-specific information associated with the connection, the udata field points to optional user data that may be returned by the destination transport user during connection establishment; and the sequence field has no meaning for this function.

The opt field implies no structure on the options that may be passed to the transport provider. The transport provider is free to specify the structure of any options passed to it. These options are specific to the underlying protocol of the transport provider. The user can choose not to negotiate protocol options by setting the len field of the opt field to 0. In this case, the provider may use default options.

The udata field enables the caller to pass user data to the destination transport user and receive user data from the destination user during connection establishment. However, the amount of user data must not exceed the limits supported by the transport provider as returned by the t_open or t_getinfo subroutine. If the len field of the udata field in the sndcall parameter is 0, no data is sent to the destination transport user.

On return, the addr, opt, and udata fields of the rcvcall parameter are updated to reflect values associated with the connection. Thus, the maxlen field of each parameter must be set before issuing this function to indicate the maximum size of the buffer for each. However, the rcvcall parameter may be null, in which case no information is given to the user on return from the t_connect subroutine.

By default, the t_connect subroutine executes in synchronous mode, and waits for the destination user's response before returning control to the local user. A successful return (that is, a return value of 0) indicates that the requested connection has been established. However, if the O_NDELAY flag is set (with the t_open subroutine or the fcntl command), the t_connect subroutine executes in asynchronous mode. In this case, the call does not wait for the remote user's response, but returns control immediately to the local user and returns -1 with the t_errno variable set to TNODATA to indicate that the connection has not yet been established. In this way, the function simply initiates the connection establishment procedure by sending a connect request to the destination transport user.

Return Values

On successful completion, the t_connect subroutine returns a value of 0. Otherwise, it returns a value of -1, and the t_errno variable is set to indicate the error.

Error Codes

If unsuccessful, the t_errno variable is set to one of the following:

Value Description
TACCES The user does not have permission to use the specified address or options.
TBADADDR The specified protocol address was in an incorrect format or contained illegal information.
TBADDATA The amount of user data specified was not within the bounds allowed by the transport provider.
TBADF The specified file descriptor does not refer to a transport end point.
TBADOPT The specified protocol options were in an incorrect format or contained illegal information.
TBUFOVFLW The number of bytes allocated for an incoming argument is not sufficient to store the value of that argument. If executed in synchronous mode, the provider's state, as seen by the user, changes to T_DATAXFER, and the connect indication information to be returned in the rcvcall parameter is discarded.
TLOOK An asynchronous event has occurred on this transport end point and requires immediate attention.
TNODATA The O_NDELAY or O_NONBLOCK flag was set, so the function successfully initiated the connection establishment procedure, but did not wait for a response from the remote user.
TNOTSUPPORT This function is not supported by the underlying transport provider.
TOUTSTATE The function was issued in the wrong sequence.
TSYSERR A system error has occurred during execution of this function.