NAME
t_rcv() — receive data or expedited data sent over a connection
SYNOPSIS
#include <xti.h> /* for X/OPEN Transport Interface - XTI */
/* or */
#include <tiuser.h> /* for Transport Layer Interface - TLI */
int t_rcv (fd, buf, nbytes, flags);
int fd;
char *buf;
unsigned nbytes;
int *flags;
DESCRIPTION
The
t_rcv()
function receives either normal or expedited data.
fd
identifies
the local transport endpoint through which data will arrive.
buf
points to a receive buffer where user data will be placed.
nbytes
specifies the size of the receive buffer.
flags
may be set on return from
t_rcv()
and specifies optional flags as described below.
By default,
t_rcv()
operates in synchronous mode and will wait for data to
arrive if none is currently available. However, if
O_NONBLOCK
is set (via
t_open()
or
fcntl()),
t_rcv()
will execute in asynchronous mode and will fail if no data is available.
(See [TNODATA] below.)
On return from the call, if
T_MORE
is set in
flags,
this indicates that
there is more data.
Thus, the current transport service data unit (TSDU) or
expedited transport service data unit (ETSDU) must be received in multiple
t_rcv()
calls. In the asynchronous mode, the
T_MORE
flag may be set on
return from the
t_rcv()
call even when the number of bytes received is
less than the size of the receive buffer specified. Each
t_rcv()
with the
T_MORE
flag set indicates that another
t_rcv()
must follow immediately to get more data for the current TSDU.
The end of the TSDU is identified by the return of a
t_rcv()
call with the
T_MORE
flag not set. If the transport provider does
not support the concept of a TSDU as indicated in the
info
argument on return from
t_open()
or
t_getinfo(),
the
T_MORE
flag is not meaningful and should be ignored. If
nbytes
is greater than zero on the call to
t_rcv(),
t_rcv()
will return 0 only if the end
of a TSDU is being returned to the user.
On return, the data returned is expedited data if
T_EXPEDITED
is set in
flags.
If the number of bytes of expedited data exceeds
nbytes,
t_rcv()
will set
T_EXPEDITED
and
T_MORE
on return from the initial call.
Subsequent calls to retrieve the remaining ETSDU will have
T_EXPEDITED
set on return. The end of the ETSDU is identified by the return of a
t_rcv()
call with the
T_MORE
flag not set.
If expedited data arrives after part of a TSDU has been retrieved, receipt of
the remainder of the TSDU will be suspended until the ETSDU has been processed.
Only after the full ETSDU has been retrieved
(T_MORE
not set) will the
remainder of the TSDU be available to the user.
In synchronous mode, the only way for the user to be notified of the arrival
of normal or expedited data is to issue this function or check for the
T_DATA
or
T_EXDATA
events using the
t_look()
function.
XTI Internet Protocol-specific Information
The
T_MORE
flag should be ignored if normal data is delivered. If a byte in
the data stream is pointed to by the TCP urgent pointer, as many bytes as
possible preceding this marked byte and the marked byte itself are denoted
as urgent data and are received with the
T_EXPEDITED
flag set. If the buffer
supplied by the user is too small to hold all urgent data, the
T_MORE
flag will
be set, indicating that urgent data still remains to be read. Note that the
number of bytes received with the
T_EXPEDITED
flag set is not necessarily
equal to the number of bytes sent by the peer user with
T_EXPEDITED
flag set.
Fork Safety
t_rcv
is not fork-safe.
RETURN VALUE
Upon successful completion,
t_rcv()
returns the number of bytes received.
Otherwise, it return -1 and
t_errno
is set to indicate the error.
ERRORS
On failure,
t_errno
is set to one of the following:
- TBADF
The specified identifier does not refer to a transport endpoint.
- TNODATA
O_NONBLOCK
was set, but no data is currently available
from the transport provider.
- TLOOK
An asynchronous event has occurred on this transport endpoint and requires
immediate attention.
- TNOTSUPPORT
This function is not supported by the underlying transport provider.
- TOUTSTATE
(XTI only) The function was issued in the wrong sequence on the endpoint
referenced by
fd.
- TSYSERR
A system error has occurred during execution of this function.
- TPROTO
(XTI only) 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).
STANDARDS CONFORMANCE
t_rcv(): SVID2, XPG3, XPG4