[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Communications, Volume 2


t_connect Subroutine for X/Open Transport Interface

Purpose

Establish a connection with another transport user.

Library

X/Open Transport Interface Library (libxti.a)

Syntax

#include <xti.h>
 
int t_connect (fd, sndcall, rcvcall)
    int fd;
    const 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. This subroutine can only be issued in the T_IDLE state.

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

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

In the sndcall parameter, the fields of the structure have the following meanings:

addr Specifies the protocol address of the destination transport user.
opt Presents any protocol-specific information that might be needed by the transport provider.
sequence Has no meaning for this subroutine.
udata Points to optional user data that may be passed to the destination transport user during connection establishment.

On return, the fields of the structure pointed to by the rcvcall parameter have the following meanings:

addr Specifies the protocol address associated with the responding transport endpoint.
opt Represents any protocol-specific information associated with the connection.
sequence Has no meaning for this subroutine.
udata Points to optional user data that may be returned by the destination transport user during connection establishment.

The opt field permits users to define the options that may be passed to the transport provider. These options are specific to the underlying protocol of the transport provider and are described for ISO and TCP protocols in Appendix A, ISO Transport Protocol Information, Appendix B, Internet Protocol-specific Information and Appendix F, Headers and Definitions. The user may choose not to negotiate protocol options by setting the len field of opt to zero. In this case, the provider may use default options.

If used, the value of the opt.buf field of the sndcall parameter netbuf structure must point to a buffer with the corresponding options; the maxlen and buf values of the addr and opt fields of the rcvcall parameter netbuf structure must be set before the call.

The udata field of the structure 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 in the connect field of the info parameter of the t_open or t_getinfo subroutines. If the value of udata.len field is zero in the sndcall parameter netbuf structure, no data will be sent to the destination transport user.

On return, the addr, opt, and udata fields of rcvcall are updated to reflect values associated with the connection. Thus, the maxlen value of each field must be set before issuing this subroutine to indicate the maximum size of the buffer for each. However, the value of the rcvcall parameter may be a null pointer, 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 (for example, return value of zero) indicates that the requested connection has been established. However, if O_NONBLOCK is set via the t_open subroutine or the fcntl parameter, the t_connect subroutine executes in asynchronous mode. In this case, the call will not wait for the remote user's response, but returns control immediately to the local user and returns -1 with t_errno set to TNODATA to indicate that the connection has not yet been established. In this way, the subroutine initiates the connection establishment procedure by sending a connect request to the destination transport user. The t_rcvconnect subroutine is used in conjunction with the t_connect subroutine to determine the status of the requested connection.

When a synchronous t_connect call is interrupted by the arrival of a signal, the state of the corresponding transport endpoint is T_OUTCON, allowing a further call to either the t_rcvconnect, t_rcvdis or t_snddis subroutines.

Parameters


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

Valid States

T_IDLE.

Return Values


0 Successful completion.
-1 t_errno is set to indicate an error.

Error Codes

On failure, t_errno is set to one of the following:

TACCES The user does not have permission to use the specified address or options.
TADDRBUSY This transport provider does not support multiple connections with the same local and remote addresses. This error indicates that a connection already exists.
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 endpoint.
TBADOPT The specified protocol options were in an incorrect format or contained illegal information.
TBUFOVFLW The number of bytes allocated for an incoming parameter (maxlen) is greater than 0 but 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_DAXAXFER, and the information to be returned in the rcvcall parameter is discarded.
TLOOK An asynchronous event has occurred on this transport endpoint and requires immediate attention.,
TNODATA O_NONBLOCK was set, so the subroutine successfully initiated the connection establishment procedure, but did not wait for a response from the remote user.
TNOTSUPPORT This subroutine is not supported by the underlying transport provider.
TOUTSTATE The subroutine was issued in the wrong sequence.
TPROTO This error indicates that a communication problem has been detected between the X/Open Transport Interface and the transport provider for which there is no other suitable X/Open Transport Interface (t_errno).
TSYSERR A system error has occurred during execution of this subroutine.

Related Information

The t_accept subroutine, t_alloc subroutine, t_getinfo subroutine, t_listen subroutine, t_open subroutine, t_optmgmt subroutine, t_rcvconnect subroutine.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]