Networking Services Library Functions tlisten(3NSL)
NAME
tlisten - listen for a connection indication
SYNOPSIS
#include
int tlisten(int fd, struct tcall *call);
DESCRIPTION
This routine is part of the XTI interfaces which evolved
from the TLI interfaces. XTI represents the future evolution
of these interfaces. However, TLI interfaces are supported
for compatibility. When using a TLI routine that has the
same name as an XTI routine, the tiuser.h header file must
be used. Refer to the TLI COMPATIBILITY section for a
description of differences between the two interfaces.
This function listens for a connection indication from a
calling transport user. The argument fd identifies the local
transport endpoint where connection indications arrive, and
on return, call contains information describing the connec-
tion indication. The parameter call points to a tcall
structure which contains the following members:
struct netbuf addr;
struct netbuf opt;
struct netbuf udata;
int sequence;
In call, addr returns the protocol address of the calling
transport user. This address is in a format usable in future
calls to tconnect(3NSL). Note, however that tconnect(3NSL)
may fail for other reasons, for example TADRBUSY. opt
returns options associated with the connection indication,
udata returns any user data sent by the caller on the con-
nection request, and sequence is a number that uniquely
identifies the returned connection indication. The value of
sequence enables the user to listen for multiple connection
indications before responding to any of them.
Since this function returns values for the addr, opt and
udata fields of call, the maxlen field of each must be set
before issuing the tlisten() to indicate the maximum size
of the buffer for each. If the maxlen field of call->addr,
call->opt or call->udata is set to zero, no information is
SunOS 5.11 Last change: 7 May 1998 1
Networking Services Library Functions tlisten(3NSL)
returned for this parameter.
By default, tlisten() executes in synchronous mode and
waits for a connection indication to arrive before returning
to the user. However, if ONONBLOCK is set via topen(3NSL)
or fcntl(2), tlisten() executes asynchronously, reducing to
a poll for existing connection indications. If none are
available, it returns -1 and sets terrno to TNODATA.
RETURN VALUES
Upon successful completion, a value of 0 is returned. Oth-
erwise, a value of -1 is returned and terrno is set to
indicate an error.
VALID STATES
TIDLE, TINCON
ERORS
On failure, terrno is set to one of the following:
TBADF The specified file descriptor does not refer
to a transport endpoint.
TBADQLEN The argument qlen of the endpoint referenced
by fd is zero.
TBUFOVFLW The number of bytes allocated for an incoming
argument (maxlen) is greater than 0 but not
sufficient to store the value of that argu-
ment. The provider's state, as seen by the
user, changes to TINCON, and the connection
indication information to be returned in call
is discarded. The value of sequence returned
can be used to do a tsnddis(3NSL).
TLOK An asynchronous event has occurred on this
transport endpoint and requires immediate
attention.
TNODATA ONONBLOCK was set, but no connection indica-
tions had been queued.
TNOTSUPORT This function is not supported by the under-
lying transport provider.
SunOS 5.11 Last change: 7 May 1998 2
Networking Services Library Functions tlisten(3NSL)
TOUTSTATE The communications endpoint referenced by fd
is not in one of the states in which a call
to this function is valid.
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 error (terrno).
TQFUL The maximum number of outstanding connection
indications has been reached for the endpoint
referenced by fd. Note that a subsequent call
to tlisten() may block until another incom-
ing connection indication is available. This
can only occur if at least one of the out-
standing connection indications becomes no
longer outstanding, for example through a
call to taccept(3NSL).
TSYSER A system error has occurred during execution
of this function.
TLI COMPATIBILITY
The XTI and TLI interface definitions have common names but
use different header files. This, and other semantic differ-
ences between the two interfaces are described in the sub-
sections below.
Interface Header
The XTI interfaces use the header file, xti.h. TLI inter-
faces should not use this header. They should use the
header:
#include
Error Description Values
The terrno values TPROT0, TBADQLEN, and TQFUL can be set
by the XTI interface but not by the TLI interface.
A terrno value that this routine can return under different
circumstances than its XTI counterpart is TBUFOVFLW. It can
be returned even when the maxlen field of the corresponding
buffer has been set to zero.
Option Buffers
SunOS 5.11 Last change: 7 May 1998 3
Networking Services Library Functions tlisten(3NSL)
The format of the options in an opt buffer is dictated by
the transport provider. Unlike the XTI interface, the TLI
interface does not fix the buffer format.
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
ATRIBUTE TYPE ATRIBUTE VALUE
MT Level Safe
SEE ALSO
fcntl(2), taccept(3NSL), talloc(3NSL), tbind(3NSL),
tconnect(3NSL), topen(3NSL), toptmgmt(3NSL),
trcvconnect(3NSL), tsnddis(3NSL), attributes(5)
WARNINGS
Some transport providers do not differentiate between a con-
nection indication and the connection itself. If this is the
case, a successful return of tlisten() indicates an exist-
ing connection.
SunOS 5.11 Last change: 7 May 1998 4
|