send.2 (2010 09)

s
send(2) send(2)
If there is enough space available in the system to buffer all of the data,
send() completes success-
fully, having written out all of the data, and returns the number of bytes written.
If there is not enough space in the buffer to write out the entire request,
send() completes success-
fully, having written as much data as possible, and returns the number of bytes it was able to write.
If there is no space in the system to buffer any of the data,
send() completes successfully, having
written no data, and returns 0.
If the
O_NDELAY flag is cleared using
fcntl(), nonblocking I/O is disabled. In this case, the send()
always executes completely (blocking as necessary) and returns the number of bytes written.
Since the
fcntl() O_NONBLOCK and O_NDELAY flags and
ioctl() FIOSNBIO requests are sup-
ported, the following clarifies on how these features interact. If the
O_NONBLOCK or O_NDELAY flag has
been set,
send() requests behave accordingly, regardless of any
FIOSNBIO requests. If neither the
O_NONBLOCK flag nor the O_NDELAY flag has been set,
FIOSNBIO requests control the behavior of
send().
By default nonblocking I/O is disabled.
The supported values for flags are zero or any combination of
MSG_OOB and MSG_EOF.
The
MSG_OOB flag is used to send out-of-band data.
The
MSG_EOF flag is used to initiate a write-side shutdown along with the send operation. Use of the
MSG_EOF flag is semantically equivalent to a send() followed immediately (if the send is successful) by
a shutdown(s, SHUT_WR). If the data send operation fails then the shutdown operation is not per-
formed. Once this flag is used in a successful send() call, no further data may be sent on the socket.
A
write() call made to a socket behaves in exactly the same way as send() with flags set to zero.
MSG_OOB is not supported for AF_UNIX or AF_VME_LINK sockets.
select() can be used to determine when it is possible to send more data.
AF_CCITT Only
Sockets of the address family AF_CCITT operate in message mode. Although they are specified as
connection-based (SOCK_STREAM) sockets, the X.25 subsystem communicates via messages. They
require that a connection be established with the
connect() or accept() calls.
The
O_NDELAY flag is not supported. Use FIOSNBIO requests to control nonblocking I/O. If the avail-
able buffer space is not large enough for the entire message and the socket is in nonblocking mode,
errno is set to [EWOULDBLOCK]. If the amount of data in the
send() exceeds the maximum out-
bound message size,
errno is set to [EMSGSIZE].
The
sendto() call is not supported.
Each call sends either a complete or a partial X.25 message. This is controlled by the setting of the
More-Data-To-Follow (MDTF) bit. If the user wants to send a partial message, MDTF should be set to 1
before the
send() call. The MDTF bit should be cleared to 0 before sending the final message fragment.
Message fragment length may range from 0 bytes up to the size of the socket’s send buffer. The MDTF bit
and multiple
send() calls can be combined to transmit complete X.25 packet sequences (zero or more
DATA packets in which the More Data bit is set, followed by one DATA packet in which the More Data bit
is clear) of arbitrary length. Note that a 0-byte message is not actually sent, but may be necessary to
flush a complete X.25 message if the user is controlling the MDTF bit.
Sockets of the AF_CCITT address family can send 1 byte of out-of-band data (known as an INTERRUPT
data packet in X.25 terminology), or up to 32 bytes if the X.25 interface is configured for 1984 CCITT X.25
recommendations. INTERRUPT data packets sent in blocking mode cause the process to block until
confirmation is received. INTERRUPT data packets sent with the socket in nonblocking mode do not
cause the process to block; instead, an out-of-band message is queued to the socket when the INTER-
RUPT confirmation packet is received (see recv (2)).
X/Open Sockets Only
For X/Open Sockets, the msghdr structure has the following form:
(UNIX 03)
struct msghdr {
void *msg_name; /* optional address */
HP-UX 11i Version 3: September 2010 3 Hewlett-Packard Company 3