Establish a connection with another transport user.
X/Open Transport Interface Library (libxti.a)
#include <xti.h> int t_connect (fd, sndcall, rcvcall) int fd; const 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. 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:
On return, the fields of the
structure pointed to by the rcvcall parameter have the following
meanings:
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.
0 | Successful completion. |
-1 | t_errno is set to indicate an error. |
On failure, t_errno is
set to one of the following:
The t_accept subroutine, t_alloc subroutine, t_getinfo subroutine, t_listen subroutine, t_open subroutine, t_optmgmt subroutine, t_rcvconnect subroutine.