'\"macro stdmacro
.if n .pH g3n.t_snd @(#)t_snd	40.6 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} t_snd 3N "Networking Support Utilities" "\&"
.if \nX=1 .ds x} t_snd 3N "Networking Support Utilities"
.if \nX=2 .ds x} t_snd 3N "" "\&"
.if \nX=3 .ds x} t_snd "" "" "\&"
.if \nX=4 .ds x} t_snd "NS_LIB" "EXTENSION" " "
.TH \*(x}
.SH NAME
\f4t_snd\f1 \- send data or expedited data over a connection
.SH SYNOPSIS
\f4#include <tiuser.h>\f1
.PP
\f4int t_snd (int fd, char \(**buf, unsigned nbytes, int flags);\f1
.SH DESCRIPTION
This function is used to send either normal or expedited data.
\f4fd\fP identifies the local transport endpoint over which data
should be sent, \f4buf\fP points to the user data,
\f4nbytes\fP specifies the number of bytes of user data to be sent, and
\f4flags\fP specifies any optional flags described below.
.PP
By default, \f4t_snd\fP
operates in synchronous 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 \f4O_NDELAY\fP or \f4O_NONBLOCK\fP is set (via \f4t_open\fP
or \f4fcntl\fP), \f4t_snd\fP
will execute in asynchronous mode, and will fail immediately if there
are flow control restrictions.
.PP \"bl86-19533
Even when there are no flow control restrictions, \f4t_snd\fP
will wait if \f4STREAMS\fP
internal resources are not available, regardless of the state of
\f4O_NDELAY\fP or \f4O_NONBLOCK\fP.
.PP
On successful completion, \f4t_snd\fP
returns the number of bytes accepted by the transport provider.
Normally this will equal the number of bytes specified in
\f4nbytes\fP.
However, if \f4O_NDELAY\fP or \f4O_NONBLOCK\fP
is set, it is possible that only part of
the data will be accepted by the transport provider.
In this case, \f4t_snd\fP will set \f4T_MORE\fP for the data that was
sent (see below) and will return a value less than \f4nbytes\fP.
If \f4nbytes\fP is zero and sending of zero bytes is not supported by
the underlying transport provider,
\f4t_snd()\fP will return \-1 with \f4t_errno\fP set to \f4TBADDATA\fP.
A return value of zero indicates that the request to send a zero-length
data message was sent to the provider.
.PP
If \f4T_EXPEDITED\fP is set in \f4flags\fP,
the data will be sent as expedited data, and will be subject to the
interpretations of the transport provider.
.PP
If \f4T_MORE\fP is set in \f4flags\fP, or is set as described above,
an indication is sent to the transport provider that the transport service
data unit (\f4TSDU\fP) or expedited transport service data unit
(\f4ETSDU\fP) is being sent through multiple \f4t_snd\fP calls.
Each \f4t_snd\fP with the \f4T_MORE\fP flag set indicates that another
\f4t_snd\fP will follow with more data for the current \f4TSDU\fP.
The end of the \f4TSDU\fP (or \f4ETSDU\fP) is identified by a
\f4t_snd\fP
call with the \f4T_MORE\fP flag not set.
Use of \f4T_MORE\fP
enables a user to break up large logical data units without losing
the boundaries of those units at the other end of the connection.
The flag implies nothing about how the data is
packaged for transfer below the transport interface.
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
The size of each \f4TSDU\fP or \f4ETSDU\fP must not exceed the limits of the
transport provider as returned by \f4t_open\fP or \f4t_getinfo\fP.
If the size is exceeded, a \f4TSYSERR\fP with system error \f4EPROTO\fP
will occur.
However, the \f4t_snd\fP may not fail because \f4EPROTO\fP errors may not
be reported immediately.
In this case, a subsequent call that accesses the transport endpoint will
fail with the associated \f4TSYSERR\fP.
.P
If \f4t_snd\fP is issued from the \f4T_IDLE\fP
state, the provider may silently discard the data.
If \f4t_snd\fP is issued from any state other than \f4T_DATAXFER\fP,
\f4T_INREL\fP or \f4T_IDLE\fP,
the provider will generate a \f4TSYSERR\fP with system error \f4EPROTO\fP
(which may be reported in the manner described above).
.P
On failure, \f4t_errno\f1 may be set to one of the following:
.TP 20
\f4[TBADF]\fP
The specified file descriptor does not refer to a transport endpoint.
.TP
\f4[TFLOW]\fP
\f4O_NDELAY\fP or \f4O_NONBLOCK\fP was set, but
the flow control mechanism prevented the transport provider from
accepting data at this time.
.TP
\f4[TNOTSUPPORT]\fP
This function is not supported by the underlying transport
provider.
.TP
\f4[TSYSERR]\fP
A system error [see \f4intro\fP(2)] has been detected during execution of
this function.
.TP
\f4[TBADDATA]\fP
\f4nbytes\fP
is zero and sending zero bytes is not supported by the transport provider.
.SH SEE ALSO
\f4t_open\fP(3N), \f4t_rcv\fP(3N).
.sp .2
\f2UNIX System V Network Programmer's Guide\f1.
.SH DIAGNOSTICS
On successful completion, \f4t_snd\fP returns the number of bytes
accepted by the transport provider, and it returns \-1 on failure and
\f4t_errno\fP is set to indicate the error.
.Ee
