t_rcv() — Receive data or expedited data sent over a connection

Standards

Standards / Extensions C or C++ Dependencies
XPG4.2 both  

Format

#define _XOPEN_SOURCE_EXTENDED 1
#include <xti.h>

int t_rcv(int fd, char *buf, unsigned int nbytes, int *flags);

General description

Receives either normal or expedited data. The argument fd identifies the local transport endpoint through which data will arrive. buf points to a receive buffer where user data is placed. nbytes specifies the size of the receive buffer. The argument 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 (using 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, and the current 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 to get more data for the current ETSDU. The end of the ETSDU is identified by the return of a t_rcv() call with the T_MORE flag not set. The T_MORE flag is not meaningful for normal data when using the TCP transport provider 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.

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. Additionally, the process can arrange to be notified by the select/poll interface.

Valid states: T_DATAXFER

Returned value

If successful, t_rcv() returns the number of bytes received.

If unsuccessful, t_rcv() returns -1 and sets errno to one of the following values:
Error Code
Description
TBADF
The specified file descriptor does not refer to a transport endpoint.
TLOOK
An asynchronous event has occurred on this transport endpoint and requires immediate attention.
TNODATA
O_NONBLOCK was set, but no data is currently available from the transport provider.
TNOTSUPPORT
This function is not supported by the underlying transport provider.
TOUTSTATE
The function was issued in the wrong sequence on the transport endpoint referenced by fd.
TPROTO
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).
TSYSERR
A system error has occurred during execution of this function.

Related information