t_accept() — Accept a connect request
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 | both |
Format
#define _XOPEN_SOURCE_EXTENDED 1
#include <xti.h>
int t_accept(int fd, int resfd, struct t_call *call);
General description
struct netbuf addr;
struct netbuf opt;
struct netbuf udata;
int sequence;
In call, addr is
the protocol address of the calling transport user. opt indicates
any options associated with the connection. udata points
to any user data to be returned to the caller, and sequence is
the value returned by t_listen() that uniquely associates the response
with a previously received connect indication. The address of the
caller, addr may be NULL (length zero). Where addr is
not NULL, then it may optionally be checked by XTI. A transport user may accept a connection on either the same, or on a different, local transport endpoint than the one on which the connect indication arrived. Before the connection can be accepted on the same endpoint (resfd==fd), the user must have responded to any previous connect indications received on that transport endpoint (using t_accept() or t_snddis() ). Otherwise, t_accept() fails and sets t_errno to TINDOUT.
If a different transport endpoint is specified (resfd!=fd), then the user may or may not choose to bind the endpoint before the t_accept() is issued. If the endpoint is not bound before the t_accept() , then the transport provider will automatically bind it to the same protocol address fd is bound to. If the transport user chooses to bind the endpoint it must be bound to a protocol address with a qlen of zero and must be in the T_IDLE state before the t_accept() is issued.
The call to t_accept() will fail with t_errno set to TLOOK if there are indications (for example, connect or disconnect) waiting to be received on the endpoint fd.
Return of user data over a connection accept is not supported under TCP, so the udata field is always meaningless.
When the user does not indicate any option (call->opt.len == 0) it is assumed that the connection is to be accepted unconditionally. The transport provider may choose options other than the defaults to ensure that the connection is accepted successfully.
Due to implementation restrictions, behavior is undefined if a different process accepts a connection pending on an endpoint than obtained it (with t_listen).
Valid states: fd: T_INCON resfd (fd!=resfd): T_IDLE
Returned value
If successful, t_accept() returns 0.
- Error Code
- Description
- TACCES
- The user does not have permission to accept a connection on the responding transport endpoint or to use the specified 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 file descriptor fd or resfd does not refer to a transport endpoint.
- TBADOPT
- The specified options were in an incorrect format or contained illegal information.
- TBADSEQ
- An invalid sequence number was specified.
- TINDOUT
- The function was called with fd==resfd but there are outstanding connection indications on the endpoint. Those other connection indications must be handled either by rejecting them using t_snddis (3) or accepting them on a different endpoint using t_accept (3).
- TLOOK
- An asynchronous event has occurred on the transport endpoint referenced by fd and requires immediate attention.
- TNOTSUPPORT
- This function is not supported by the underlying transport provider.
- TOUTSTATE
- The function was called in the wrong sequence on the transport endpoint referenced by fd, or the transport endpoint referred to by resfd is not in the appropriate state.
- TPROTO
- This error indicates that a communication problem has been detected between XTI and the transport provider for which there is no other suitable XTI (t_errno).
- TPROVMISMATCH
- The file descriptors fd and resfd do not refer to the same transport provider.
- TRESADDR
- This transport provider requires both fd and resfd to be bound to the same address. This error results if they are not.
- TRESQLEN
- The endpoint referenced by resfd (where resfd != fd) was bound to a protocol address with a qlen that is greater than 0.
- TSYSERR
- A system error has occurred during execution of this function.
Related information
- xti.h
- t_connect() — Establish a connection with another transport user
- t_getstate() — Get the current state
- t_listen() — Listen for a connect indication
- t_open() — Establish a transport endpoint
- t_optmgmt() — Manage options for a transport endpoint
- t_rcvconnect() — Receive the confirmation from a connect request