'\"macro stdmacro
.if n .pH g3n.t_accept @(#)t_accept	40.6 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} t_accept 3N "Networking Support Utilities" "\&"
.if \nX=1 .ds x} t_accept 3N "Networking Support Utilities"
.if \nX=2 .ds x} t_accept 3N "" "\&"
.if \nX=3 .ds x} t_accept "" "" "\&"
.if \nX=4 .ds x} t_accept "NS_LIB" "EXTENSION" " "
.TH \*(x}
.SH NAME
\f4t_accept\f1 \- accept a connect request
.SH SYNOPSIS
\f4#include <tiuser.h>\f1
.PP
\f4int t_accept ( int fd, int resfd, struct t_call \(**call);\f1
.SH DESCRIPTION
This function is issued by a transport user
to accept a connect request.
\f4fd\f1
identifies the local transport endpoint where the connect
indication arrived,
\f4resfd\f1
specifies the local transport endpoint
where the connection is to be established,
and
\f4call\f1
contains information required by the transport provider to complete the connection.
\f4call\fP points to a \f4t_call\f1 structure that contains the following
members:
.PP
.RS
\f4struct netbuf addr;\fP
.br
\f4struct netbuf opt;\fP
.br
\f4struct netbuf udata;\fP
.br
\f4int sequence;\fP
.RE
.PP
\f4netbuf\f1 is described in \f4intro\fP(3).
In \f4call\f1, \f4addr\f1 is the address of the caller, \f4opt\f1
indicates any protocol-specific parameters associated with the connection,
\f4udata\f1
points to any user data to be returned to the caller, and
\f4sequence\f1
is the value returned by
\f4t_listen\fP
that uniquely associates the response with a
previously received connect indication.
.PP
A transport user may accept a connection on either the same, or on a different, local transport endpoint from the one on which the connect indication arrived.
If the same endpoint is specified (i.e., \f4resfd\f1=\f4fd\f1),
the connection can be accepted unless the following condition is true:
The user has received other indications on that endpoint but has not responded to them (with
\f4t_accept\fP
or
\f4t_snddis\fP).
For this condition,
\f4t_accept\fP
will fail and set \f4t_errno\f1 to \f4TBADF\fP.
.PP
If a different transport endpoint is specified (\f4resfd\f1!=\f4fd\f1),
the endpoint must be bound to a protocol address and must be
in the \f4T_IDLE\fP state [see \f4t_getstate\fP(3N)] before the
\f4t_accept\fP is issued.
.PP
For both types of endpoints,
\f4t_accept\fP
will fail and set
\f4t_errno\fP
to \f4TLOOK\fP
if there are indications (e.g., a connect or disconnect) waiting to be received on that endpoint.
.PP
The values of parameters specified by
\f4opt\f1
and the syntax of those values are protocol specific.
The
\f4udata\f1
argument enables the called transport user to send user data to the
caller and
the amount of user data must not exceed the limits supported by
the transport provider as returned in the \f4connect\fP field of the
\f4info\fP argument of \f4t_open\fP or \f4t_getinfo\fP.
If the \f4len\f1 [see \f4netbuf\f1 in \f4intro\fP(3)] field of \f4udata\f1
is zero, no data will be sent to the caller.
.P
On failure,
\f4t_errno\fP
may be set to one of the following:
.TP 19
\f4[TBADF]\fP
The specified file descriptor does not refer to a transport endpoint,
or the user is illegally accepting a connection on the same
transport endpoint on which the connect indication arrived.
.TP
\f4[TOUTSTATE]\fP
The function was issued in the wrong sequence on the transport endpoint referenced by \f4fd\f1,
or the transport endpoint referred to by \f4resfd\f1 is not in the \f4T_IDLE\fP state.
.TP
\f4[TACCES]\fP
The user does not have permission to accept a connection on the responding
transport endpoint or use the specified options.
.TP
\f4[TBADOPT]\fP
The specified options were in an incorrect format or contained illegal
information.
.TP
\f4[TBADDATA]\fP
The amount of user data specified was not within the bounds allowed by
the transport provider.
.TP
\f4[TBADSEQ]\fP
An invalid sequence number was specified.
.TP
\f4[TLOOK]\fP
An asynchronous event has occurred on the transport endpoint referenced by \f4fd\f1 and requires
immediate attention.
.TP
\f4[TNOTSUPPORT]\fP
This function is not supported by the underlying transport
provider.
.TP
\f4[TSYSERR]\fP
A system error has occurred during execution of this function.
.SH SEE ALSO
.na
\f4intro\fP(3),
\f4t_connect\fP(3N),
\f4t_getstate\fP(3N),
\f4t_listen\fP(3N),
\f4t_open\fP(3N),
\f4t_rcvconnect\fP(3N).
.sp .2
\f2UNIX System V Network Programmer's Guide\f1.
.ad
.SH DIAGNOSTICS
Upon successful completion, a value of 0 is returned.
Otherwise, a value of \-1 is returned and
\f4t_errno\f1 is set to indicate the error.
.Ee
