[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Communications, Volume 2

t_listen Subroutine for X/Open Transport Interface


Listen for a connect indication.


X/Open Transport Interface Library (libxti.a)


#include <xti.h>

int t_listen (fd, call)
int fd;
struct t_call *call;


The t_listen subroutine listens for a connect request from a calling transport user.

By default, the t_listen subroutine executes in synchronous mode and waits for a connect indication to arrive before returning to the user. However, if O_NONBLOCK is set via the t_open subroutine or with the fcntl subroutine (F_SETFL), the t_listen subroutine executes asynchronously, reducing to a poll for existing connect indications. If none are available, the subroutine returns -1 and sets t_errno to TNODATA.


fd Identifies the local transport endpoint where connect indications arrive.
call Contains information describing the connect indication. The parameter call points to a t_call structure which contains the following members:

struct netbuf addr;
struct netbuf opt;
struct netbuf udata;
int sequence;

In this structure, the fields have the following meanings:

Returns the protocol address of the calling transport user. This address is in a format usable in future calls to the t_connect subroutine. Note, however that t_connect may fail for other reasons, for example, TADDRBUSY.

Returns options associated with the connect request.

Returns any user data sent by the caller on the connect request.

A number that uniquely identifies the returned connect indication. The value of sequence enables the user to listen for multiple connect indications before responding to any of them.

Since this subroutine returns values for the addr, opt and udata fields of the call parameter, the maxlen field of each must be set before issuing the t_listen subroutine to indicate the maximum size of the buffer for each.

Valid States


Return Values

0 Successful completion.
-1 t_errno is set to indicate an error.

Error Codes

On failure, t_errno is set to one of the following:

TBADF The specified file descriptor does not refer to a transport endpoint.
TBADQLEN The qlen parameter of the endpoint referenced by the fd parameter is zero.
TBODATA O_NONBLOCK was set, but no connect indications had been queued.
TBUFOVFLW The number of bytes allocated for an incoming parameter (maxlen) is greater than 0 but not sufficient to store the value of that parameter. The provider's state, as seen by the user, changes to T_INCON, and the connect indication information to be returned in the call parameter is discarded. The value of the sequence parameter returned can be used to do a t_snddis.
TLOOK An asynchronous event has occurred on the transport endpoint and requires immediate attention.
TNOTSUPPORT This subroutine is not supported by the underlying transport provider.
TOUTSTATE The subroutine was issued in the wrong sequence on the transport endpoint referenced by the fd parameter.
TPROTO This error indicates that a communication problem has been detected between the X/Open Transport Interface and the transport provider for which there is no other suitable X/Open Transport Interface (t_errno).
TQFULL The maximum number of outstanding indications has been reached for the endpoint referenced by the fd parameter.
TSYSERR A system error has occurred during execution of this subroutine.

Implementation Specifics

Some transport providers do not differentiate between a connect indication and the connection itself. If this is the case, a successful return of t_listen indicates an existing connection (see Appendix B, Internet Protocol-specific Information).

Related Information

The fcntl subroutine, t_accept subroutine, t_alloc subroutine, t_bind subroutine, t_connect subroutine, t_open subroutine, t_optmgmt subroutine, t_rcvconnect subroutine.

[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]