t_listen() — Listen for a connect indication
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 | both |
Format
#define _XOPEN_SOURCE_EXTENDED 1
#include <xti.h>
int t_listen(int fd, struct t_call *call);
General description
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 t_connect(). However, t_connect()
may fail for other reasons; For example TADDRBUSY. opt returns
options associated with the connect request. udata is meaningless
because transmission of user data is not supported across a connect
request. sequence is 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 function returns values for the addr, opt and udata fields of call, the maxlen field of each must be set before issuing the t_listen() to indicate the maximum size of the buffer for each.
By default, t_listen() executes in synchronous mode and waits for a connect indication to arrive before returning to the user. However, if O_NONBLOCK is set using t_open() or fcntl(), t_listen() executes asynchronously, reducing to a poll for existing connect indications. If none are available, it returns -1 and sets t_errno to TNODATA.
Valid states: T_IDLE, T_INCON
Returned value
If successful, t_listen() returns 0. The TCP transport provider does not differentiate between a connect indication and the connection itself. A successful return of t_listen() indicates an existing connection.
- Error Code
- Description
- 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 argument. The provider's state, as seen by the user, changes to T_INCON, and the connect indication information to be returned in call is discarded. The value of sequence returned can be used to do a t_snddis() .
- TLOOK
- An asynchronous event has occurred on this transport endpoint and requires immediate attention.
- TNODATA
- O_NONBLOCK was set, but no connect indications had been queued.
- TNOTSUPPORT
- This function is not supported by the underlying transport provider.
- TOUTSTATE
- The function was issued in the wrong sequence on the transport endpoint referenced by fd.
- 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).
- TQFULL
- The maximum number of outstanding indications has been reached for the endpoint referenced by fd.
- TSYSERR
- A system error has occurred during execution of this function.
Related information
- xti.h
- fcntl() — Control open file descriptors
- t_accept() — Accept a connect request
- t_alloc() — Allocate a library structure
- t_bind() — Bind an address to a transport endpoint
- t_connect() — Establish a connection with another transport user
- t_open() — Establish a transport endpoint
- t_optmgmt() — Manage options for a transport endpoint
- t_rcvconnect() — Receive the confirmation from a connect request