|
Description
The user can receive a datagram from another user in connectionless mode with the t_rcvudata() function.
The fd parameter specifies the local transport endpoint over which the datagram is received.
After t_rcvudata() is executed, flags informs the user whether the datagram was received in full.
unitdata is a pointer to an object of type struct t_unitdata in which t_rcvudata() returns information about the received datagram.
The t_unitdata structure is declared in <xti.h> as follows:
struct t_unitdata { struct netbuf addr; struct netbuf opt; struct netbuf udata; };
Before calling t_rcvudata(), the user must supply the maxlen component in the separatenetbuf structures of *unitdata with the maximum values of each buffer size.
After t_rcvudata() is executed, unitdata->addr contains the protocol address of the sender, unitdata->opt contains protocol-specific options for the received datagram and unitdata->udata contains the received user data.
By default, t_rcvudata() works in synchronous mode, i.e. t_rcvudata() waits for a datagram to arrive and blocks if no datagrams are currently available.
However, if O_NDELAY or O_NONBLOCK was previously set with t_open() or the POSIX fcntl() function for the transport endpoint specified by fd, t_rcvudata() works in asynchronous mode and terminates with an error if no datagrams are available. t_rcvudata() then returns the value -1 and sets t_errno to TNODATA.
If the buffer in unitdata->udata is too small to store the datagram, t_rcvudata() stores as much of the datagram as possible in the buffer and sets the T_MORE flag. The T_MORE flag indicates that an additional t_rcvudata() call is needed to receive the remaining part of the datagram. Until the datagram is completely received, subsequent t_rcvudata() calls return the value 0 for the lengths of the protocol address and options.
Return value
0:
If successful.
-1:
If an error occurs. t_ errno is set to indicate the error.
Errors
TBADF
The specified file descriptor does not reference a transport endpoint.
TBUFOVFLW
The number of bytes that were reserved for the protocol address to be returned or the options, is too small to store this information. The information that should be returned in *unitdata is deleted.
TLOOK
An asynchronous event occurred on the transport endpoint passed in fd and this must be processed immediately.
TNODATA
O_NDELAY or O_NONBLOCK was set but there are currently no datagrams available from the transport provider.
TNOTSUPPORT
This function is not supported by the underlying transport provider.
TOUTSTATE
The function was called in the wrong position within a sequence of XTI function calls for
transport endpoint fd.
TSYSERR
A system error occurred during execution of this function.
In this case, the errno error variable contains more detailed information:
EFAULT | The area specified in unitdata->addr, unitdata->opt or unitdata->udata is outside the process address range. |
ETIME | The datagram was deleted because a transport system-dependent time limit was exceeded (see also "Dependencies on the BS2000 transport system BCAM"). |
EINTR | The call was interrupted by a signal. |