|
Description
The user calls the t_connect() function to send a connection request over local transport endpoint fd to another transport user who is specified by the protocol address passed with the sndcall parameter.
The sndcall and rcvcall parameters each point to an object of type struct t_call.
The t_call structure is declared in <xti.h> as follows:
struct t_call { struct netbuf addr; struct netbuf opt; struct netbuf udata; int sequence; };
The caller of t_connect() passes information in sndcall that the transport provider needs to send a connection request:
sndcall->addr contains the protocol address of the transport endpoint to which the connection request is to be sent.
sndcall->opt contains protocol-specific information which the transport provider needs. However, sndcall->opt does not specify the structure of the options as the transport provider himself defines the structure of all options passed to him. These options are specific to the underlying protocol of the transport provider.
If the user passes the value 0 in sndcall->opt.len, the transport provider selects default options and the user does not have to negotiate them with the transport provider.
Since sending user data is not supported, sndcall->udata is meaningless for t_connect(). sndcall->sequence is also meaningless for t_connect().
After successful execution, t_connect() returns information in rcvcall about the connection that was just set up.
rcvcall->addr contains the protocol address of the transport endpoint which accepted the connection request with t_accept().
Before calling t_connect() the user must make the maximum length of the result buffer (rcval->addr.buf) known in rcval->addr.maxlen.rcval->opt contains protocol-specific information concerning the newly set up connection.
Before calling t_connect() the user must make the maximum length of the result buffer (rcval->opt.buf) known in rcval->opt.maxlen.
Since receiving user data is not supported, rcvcall->udata is meaningless for t_connect(). rcvcall->sequence is also meaningless for t_connect().
By default, t_connect() works in synchronous mode and waits (blocks) until a reply arrives from the destination user, i.e. transport user, to which the connection request was sent. t_connect() only relinquishes control back to the calling transport user after receiving the reply. Successful execution of t_connect() (return value 0) indicates that the requested connection has been set up.
However, t_connect() is executed in asynchronous mode if t_open() or the POSIX fcntl() function was used previously to set O_NDELAY or O_NONBLOCK for the transport endpoint specified by fd. In asynchronous mode, t_connect() does not wait for the reply from the destination user, but relinquishes control back to the calling user immediately after getting the status of the connection request. If the requested connection has not been set up yet, t_connect() returns the value -1 and sets t_errno to TNODATA.
In other words, t_connect() initiates the connection setup in asynchronous mode simply by sending a connection request to the destination user. The local user can get the status of the requested connection with the t_rcvconnect() function.
Return value
0:
If successful.
-1:
If an error occurs. t_ errno is set to indicate the error.
Errors
TACCES
The user has no allowance to use the specified address or options.
TBADADDR
The specified protocol address has the wrong format or contains invalid information.
TBADDATA
Sending user data is not supported.
TBADF
The specified file descriptor does not reference a transport endpoint.
TBADOPT
The specified protocol options had the wrong format or contained invalid information.
TBUFOVFLW
The number of bytes that were reserved for a result parameter are not enough to store the parameter value. If synchronous mode is being used, the state of the transport provider from the user viewpoint is set to T_DATAXFER and the information for the connection request, which should be returned in *rcvcall, is removed.
TLOOK
An asynchronous event occurred on the transport endpoint passed in fd and this must be processed immediately.
TNODATA
O_NDELAY or O_NONBLOCK was set so that the function could initiate connection setup procedure successfully but does not wait for a reply from the remote user.
TNOTSUPPORT
This function is not supported by the underlying transport provider.
TOUTSTATE
The function was called in the wrong position within a sequence of XTI function calls for transport endpoint fd.
TSYSERR
A system error occurred during execution of this function.
See also
t_accept(), t_getinfo(), t_listen(), t_open(), t_optmgmt(), t_rcvconnect(), fcntl()