'\"macro stdmacro
.if n .pH g3n.t_rcv @(#)t_rcv	40.5 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} t_rcv 3N "Networking Support Utilities" "\&"
.if \nX=1 .ds x} t_rcv 3N "Networking Support Utilities"
.if \nX=2 .ds x} t_rcv 3N "" "\&"
.if \nX=3 .ds x} t_rcv "" "" "\&"
.if \nX=4 .ds x} t_rcv "NS_LIB" "EXTENSION" " "
.TH \*(x}
.SH NAME
\f4t_rcv\f1 \- receive data or expedited data sent over a connection
.SH SYNOPSIS
\f4int t_rcv (int fd, char \(**buf, unsigned nbytes, int \(**flags);\f1
.SH DESCRIPTION
This function receives either normal or expedited data.
\f4fd\fP
identifies the local transport endpoint through which data will arrive,
\f4buf\fP
points to a receive buffer where user data will be placed, and
\f4nbytes\fP
specifies the size of the receive buffer.
\f4flags\fP
may be set on return from
\f4t_rcv\fP
and specifies optional flags as described below.
.PP
By default, \f4t_rcv\fP
operates in synchronous mode and will
wait for data 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_rcv\fP
will execute in asynchronous mode and will 
fail if no data is available.
(See \f4TNODATA\fP below.)
.PP
On return from the call,
if \f4T_MORE\fP is set in
\f4flags\fP,
this indicates that there is more data and the current
transport service data unit (\f4TSDU\fP) or expedited transport
service data unit (\f4ETSDU\fP)
must be received in multiple
\f4t_rcv\fP
calls.
Each
\f4t_rcv\fP
with the \f4T_MORE\fP flag set indicates that another
\f4t_rcv\fP
must follow to get more data for the current \f4TSDU\fP.
The end of the \f4TSDU\fP is identified by the return of a
\f4t_rcv\fP
call with the \f4T_MORE\fP flag not set.
If the transport provider does not support the concept of a \f4TSDU\fP
as indicated in the
\f4info\fP
argument on return from
\f4t_open\fP
or
\f4t_getinfo\fP,
the
\f4T_MORE\fP
flag is not meaningful and should be ignored.
.PP
On return, the data returned is expedited data
if \f4T_EXPEDITED\fP is set in \f4flags\f1.
If the number of bytes of expedited data exceeds
\f4nbytes\fP,
\f4t_rcv\fP
will set \f4T_EXPEDITED\fP and \f4T_MORE\fP on return from the initial call.
Subsequent calls to retrieve the remaining \f4ETSDU\fP will have
\f4T_EXPEDITED\fP set on return.
The end of the \f4ETSDU\fP is identified by the return of a
\f4t_rcv\fP call with the \f4T_MORE\fP flag not set.
.P
If expedited data arrives after part of a \f4TSDU\fP has
been retrieved, receipt of the remainder of the \f4TSDU\fP
will be suspended until the \f4ETSDU\fP has been processed.
Only after the full \f4ETSDU\fP has been retrieved (\f4T_MORE\fP not set)
will the remainder of the \f4TSDU\fP be available to the user.
.P
On failure, \f4t_errno\f1 may be set to one of the following:
.TP 19
\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 is currently available from the transport provider.
.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
\f4t_open\fP(3N), \f4t_snd\fP(3N).
.sp .2
\f2UNIX System V Network Programmer's Guide\f1.
.SH DIAGNOSTICS
On successful completion, \f4t_rcv\fP returns the number of bytes
received, and it returns \-1 on failure and \f4t_errno\fP
is set to indicate the error.
.Ee
