'\"macro stdmacro
.if n .pH g3n.t_rcvudata @(#)t_rcvudata	40.5 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} t_rcvudata 3N "Networking Support Utilities" "\&"
.if \nX=1 .ds x} t_rcvudata 3N "Networking Support Utilities"
.if \nX=2 .ds x} t_rcvudata 3N "" "\&"
.if \nX=3 .ds x} t_rcvudata "" "" "\&"
.if \nX=4 .ds x} t_rcvudata "NS_LIB" "EXTENSION" " "
.TH \*(x}
.SH NAME
\f4t_rcvudata\f1 \- receive a data unit
.SH SYNOPSIS
\f4#include <tiuser.h>\f1
.PP
\f4int t_rcvudata (int fd, struct t_unitdata \(**unitdata, int \(**flags);\f1
.SH DESCRIPTION
This function is used
in connectionless mode
to receive a data unit from another transport
user.
\f4fd\fP
identifies the local transport endpoint through which data will be
received,
\f4unitdata\fP
holds information associated with the received data unit, and
\f4flags\fP
is set on return to indicate that the complete data unit was not
received.
\f4unitdata\fP
points to a \f4t_unitdata\f1 structure containing the following members:
.PP
.RS
.ft4
struct netbuf addr;
.br
struct netbuf opt;
.br
struct netbuf udata;
.ftP
.RE
.PP
The
\f4maxlen\fP
[see \f4netbuf\f1 in \f4intro\fP(3)] field of
\f4addr\fP,
\f4opt\fP,
and
\f4udata\fP
must be set before issuing this function to indicate the maximum
size of the buffer for each.
.PP
On return from this call,
\f4addr\fP
specifies the protocol address of the sending user,
\f4opt\fP
identifies protocol-specific options that were
associated with this data unit, and
\f4udata\fP
specifies the user data that was received.
.PP
By default,
\f4t_rcvudata\fP
operates in synchronous mode and will
wait for a data unit to arrive if none is currently available.
However, if
\f4O_NDELAY\fP
or
\f4O_NONBLOCK\fP
is set (via
\f4t_open\fP
or
\f4fcntl\fP),
\f4t_rcvudata\fP
will execute in asynchronous mode and will fail
if no data units are available.
.PP
If the buffer defined in the
\f4udata\fP
field of
\f4unitdata\fP
is not large enough to hold the current data unit,
the buffer will be filled and
\f4T_MORE\fP
will be set in
\f4flags\fP
on return to indicate that another
\f4t_rcvudata\fP
should be issued to retrieve the rest of the data unit.
Subsequent
\f4t_rcvudata\fP
call(s) will return zero for the length of the address and options
until the full data unit has been received.
.P
On failure, \f4t_errno\f1 may be set to one of the following:
.TP 20
\f4[TBADF]\fP
The specified file descriptor does not refer to a transport endpoint.
.TP
\f4[TNODATA]\fP
\f4O_NDELAY\fP or \f4O_NONBLOCK\fP was set, but
no data units are currently available from the transport provider.
.TP
\f4[TBUFOVFLW]\fP
The number of bytes allocated for the incoming protocol address or
options is not sufficient to store the information.
The unit data information to be returned in \f4unitdata\fP
will be discarded.
.TP
\f4[TLOOK]\fP
An asynchronous event has occurred on this transport endpoint and requires
immediate attention.
.TP
\f4[TNOTSUPPORT]\fP
This function is not supported by the underlying transport
provider.
.TP
\f4[TSYSERR]\fP
A system error has occurred during execution of this function.
.SH SEE ALSO
\f4intro\fP(3), \f4t_rcvuderr\fP(3N), \f4t_sndudata\fP(3N).
.sp .2
\f2UNIX System V Network Programmer's Guide\f1.
.SH DIAGNOSTICS
\f4t_rcvudata\fP returns 0 on successful completion and \-1 on failure
and \f4t_errno\f1 is set to indicate the error.
.Ee
