Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

t_listen() - wait for connection requests

&pagelevel(4)&pagelevel

#include <xti.h>

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

Description

The user calls the t_listen() function to monitor transport endpoint fd passively for connection requests which other transport endpoints send to fd with t_connect(). After execution of t_listen(), the call parameter points an object of type struct t_call which contains information about incoming connection requests.

The t_call structure is declared in <xti.h> as follows:

struct t_call {
   struct netbuf addr;
   struct netbuf opt;
   struct netbuf udata;
   int sequence;
};

t_listen() returns the protocol address of the transport service user who sent the connection request, in call->addr.buf. Before calling t_listen(), the user must specify the maximum size of the call->addr.buf result buffer in call->addr.maxlen.

Returning protocol-specific parameters in call->opt and user data in call->udata are not supported.

After execution of t_listen(), the value of call->sequence uniquely identifies the connection request which arrived, allowing the user to monitor several connection requests before replying to one of them.

By default, t_listen() works in synchronous mode, waits (blocks) if no connection requests are available and only returns control to the user after a connection request arrives.However, if the user previously set O_NDELAY or O_NONBLOCK with t_open() or the POSIX fcntl() function, t_listen() works in asynchronous mode. t_listen() then only polls for pending connection requests (poll()) and does not wait. If no connection requests are available, t_listen() returns the value -1 and sets t_errno to TNODATA.

Return value

0:

If successful.

-1:

If an error occurs. t_ errno is set to indicate the error.

Errors

TBADF

The specified file descriptor does not reference a transport endpoint.

TBADQLEN

The qlen value of the transport endpoint to which fd refers is 0.

TBUFOVFLW

The number of bytes reserved (with maxlen) for a result parameter is not enough to store the value of the parameter. The state of the transport provider changes to T_INCON from the viewpoint of the user. The information about the connection request which is to be returned in *call, is deleted.

TLOOK

An asynchronous event occurred on the transport endpoint passed in fd and this must be processed immediately.

TNODATA

O_NDELAY or O_NONBLOCK is set but there are no connection requests in the queue.

TNOTSUPPORT

This function is not supported by the underlying transport provider.

TPROTO

The connection to the BCAM transport system has been shut down.

TSYSERR

A system error occurred during execution of this function.

See also

t_accept(), t_bind(), t_connect(), t_open(), t_rcvconnect(), fcntl()