HP-UX Reference (11i v2 07/12) - 3 Library Functions N-Z (vol 7)

t
t_listen(3) t_listen(3)
NAME
t_listen() - listen for a connect request
SYNOPSIS
#include <xti.h> /* for X/OPEN Transport Interface - XTI */
/* or */
#include <tiuser.h> /* for Transport Layer Interface - TLI */
int t_listen (fd, call);
int fd;
struct t_call *call;
DESCRIPTION
The t_listen() function listens for a connect request from a calling transport user. fd identifies the
local transport endpoint where connect indications arrive. On return, 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;
The type netbuf structure is defined in the <xti.h> or <tiuser.h> header file. This structure,
which is used to define buffer parameters, has the following members:
unsigned int maxlen maximum byte length of the data buffer
unsigned int len actual byte length of data written to buffer
char *buf points to buffer location
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() . Note, however that t_connect() may fail for other reasons, for
example [TADDRBUSY].
opt returns protocol-specific parameters associated with the connect request. For XTI over the OSI tran-
sport provider, struct isoco_options
should be used. For TLI, see the documentation for the transport
provider being used.
udata returns any user data sent by the caller on the 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 (via 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].
Thread-Safeness
The t_listen() function is safe to be called by multithreaded applications, and it is thread-safe for both
POSIX Threads and DCE User Threads. It has a cancellation point. It is neither async-cancel safe nor
async-signal safe. Finally, it is not fork-safe.
Valid States
T_IDLE, T_INCON
Caveats
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, "Inter-
net Protocol-specific Information," of the CAE Specification X/Open Transport Interface (XTI) manual).
RETURN VALUE
Upon successful completion, a value of 0 is returned Otherwise, a value of −1 it returned and
t_errno is
set to indicate the error.
504 Hewlett-Packard Company − 1 − HP-UX 11i Version 2: December 2007 Update