Establishes a connection with another transport user.
Transport Layer Interface Library (libtli.a)
int t_connect(fd, sndcall, rcvcall) int fd; struct t_call *sndcall; struct t_call *rcvcall;
The t_connect subroutine enables a transport user to request a connection to the specified destination transport user.
|Identifies the local transport end point where communication will be established.
|Specifies information needed by the transport provider to establish a connection.
|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.
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.
If unsuccessful, the t_errno variable is set to one of the following:
|The user does not have permission to use the specified address or options.
|The specified protocol address was in an incorrect format or contained illegal information.
|The amount of user data specified was not within the bounds allowed by the transport provider.
|The specified file descriptor does not refer to a transport end point.
|The specified protocol options were in an incorrect format or contained illegal information.
|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.
|An asynchronous event has occurred on this transport end point and requires immediate attention.
|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.
|This function is not supported by the underlying transport provider.
|The function was issued in the wrong sequence.
|A system error has occurred during execution of this function.
This subroutine is part of Base Operating System (BOS) Runtime.
The fcntl command.
The t_accept subroutine, t_getinfo subroutine, t_listen subroutine, t_open subroutine, t_optmgmt subroutine, t_rcvconnect subroutine.
List of Streams Programming References and STREAMS Overview in AIX Version 4.3 Communications Programming Concepts.