NAME
t_sndudata() — send a data unit
SYNOPSIS
#include <xti.h> /* for X/OPEN Transport Interface - XTI */
/* or */
#include <tiuser.h> /* for Transport Layer Interface - TLI )"
int t_sndudata(fd, unitdata);
int fd;
struct t_unitdata *unitdata;
DESCRIPTION
The
t_sndudata()
function is used in connectionless mode to send a data unit to another
transport user. The argument
fd
identifies the local transport endpoint
through which data is sent. The argument
unitdata
points to a type
t_unitdata
structure used to specify a data unit being sent through the
transport endpoint specified by the
fd
parameter. The
t_unitdata
structure has the following members:
struct netbuf addr;
struct netbuf opt;
struct netbuf udata;
The type netbuf structure is defined in the
<xti.h>
or
<tiuser.h>
header file. This structure, which is used to define buffer parameters,
has the following members:
- unsigned int maxlen
maximum byte length of the data buffer
- unsigned int len
actual byte length of data written to buffer
- char *buf
points to buffer location
In
unitdata,
addr
specifies the protocol address of the destination user,
opt
identifies protocol-specific options that the user wants associated
with this request and
udata
specifies the user data to be sent. The user
may choose not to specify what protocol options are associated with the
transfer by setting the
len
field of
opt
to zero. In this case, the provider may use default options.
If the
len
field of
udata
is zero, and sending of zero octets is
not supported by the underlying transport service, the
t_sndudata()
will return -1 with
t_errno
set to [TBADDATA].
By default,
t_sndudata()
executes in the synchronous operating mode and
may wait if flow control restrictions prevent the data from being
accepted
by the local transport provider at the time the call is made.
However, if
O_NONBLOCK
is set (via
t_open()
or
fcntl()),
t_sndudata()
will execute in asynchronous mode and will fail under such
conditions. The process can arrange to be notified of the clearance
restriction via either
t_look()
or the EM interface.
If the amount of data specified in
udata
exceeds the TSDU size as returned
in the
tsdu
field of the
info
argument of
t_open()
or
t_getinfo(),
a [TBADDATA] error will be generated. If
t_sndudata()
is called before the destination user has activated its transport
endpoint, the data unit may be discarded.
If it is not possible for the transport provider to immediately detect the
conditions that cause errors [TBADADDR] and [TBADOPT], then these errors will
alternatively be returned by
t_rcvuderr().
Therefore, an application
must be prepared to receive these errors both of these ways.
Fork Safety
t_sndudata
is not fork-safe.
RETURN VALUE
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1
is returned and
t_errno
is set to indicate the error.
ERRORS
On failure,
t_errno
is set to one of the following:
- [TBADDATA]
Illegal amount of data. Zero octets is not supported.
- [TBADF]
The specified file descriptor does not refer to a transport endpoint.
- [TFLOW]
Asynchronous mode is indicated because
O_NONBLOCK
was
set, but the transport provider cannot accept the data because of flow-control
restrictions.
- [TLOOK]
(XTI only) 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
t_sndudata()
function was issued in the wrong sequence on
the transport endpoint referenced by the
fd
parameter.
- [TSYSERR]
A system error occurred during execution of this function.
A protocol error may not cause the
t_sndudata()
function to fail until a subsequent call is
made to access the transport endpoint specified by the
fd
parameter.
- [TBADADDR]
The specified protocol address was in an incorrect format or contained
illegal information.
- [TBADOPT]
The specified options were in an incorrect format or contained illegal
information.
- [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).
STANDARDS CONFORMANCE
t_sndudata(): SVID2, XPG3, XPG4