HP-UX Reference (11i v1 05/09) - 2 System Calls (vol 5)

s
send(2) send(2)
returned, and errno is set to [EMSGSIZE]. For SOCK_DGRAM sockets, this size is fixed by the imple-
mentation (see the DEPENDENCIES section). Otherwise there is no size limit.
When send() or sendto() returns a positive value, it only indicates this number of bytes have been
sent to the local transport provider. It does not mean this number of bytes have been delivered to the peer
socket application. A SOCK_DGRAM socket does not guarantee end-to-end delivery. A SOCK_STREAM
socket guarantees eventual end-to-end delivery, however its underlying transport provider may later detect
an irrecoverable error and returns a value of
1 at another socket function call.
When send() or
sendto() returns a value of
1 , it indicates a locally detected error. errno is set to
indicate the error.
sendmsg() performs the same action as send(), but it gathers the output data from the buffers
specified in the
msghdr structure (see
_XOPEN_SOURCE_EXTENDED Only
below). This structure is
defined in
<sys/socket.h>
and has the following form (
HP-UX BSD Sockets Only):
struct msghdr {
caddr_t msg_name; /* optional address */
int msg_namelen; /* size of address */
struct iovec *msg_iov; /* scatter array for data */
int msg_iovlen; /* # of elements in msg_iov */
caddr_t msg_accrights; /* access rights */
int msg_accrightslen; /* size of msg_accrights */
}
msg_name points to a sockaddr structure in which the address of the destination socket should be
stored, if the socket is connectionless; msg_name may be a null pointer if no name is specified. msg_iov
specifies the locations of the character arrays for storing the outbound data. msg_accrights specifies a
buffer that contains any access rights to be sent along with the message. Access rights are limited to file
descriptors of size int. If access rights are not being transferred, set the msg_accrights field to NULL.
Access rights are supported only for AF_UNIX.
If no buffer space is available to hold the data to be transmitted,
send() blocks unless nonblocking mode
is enabled. The three ways to enable nonblocking mode are:
with the
FIOSNBIO ioctl() request,
with the O_NONBLOCK flag, and
with the O_NDELAY fcntl() flag.
If nonblocking I/O is enabled using FIOSNBIO or the equivalent FIONBIO request (defined in
<sys/ioctl.h> and explained in ioctl(2), ioctl(5), and socket(7)), although the use of
FIONBIO is not
recommended, the
send() request completes in one of three ways:
If there is enough space available in the system to buffer all of the data,
send() completes suc-
cessfully, 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 suc-
cessfully, 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() fails, having written no data,
and errno is set to [EWOULDBLOCK].
If nonblocking I/O is disabled using FIOSNBIO, send() always executes completely (blocking as neces-
sary) and returns the number of bytes written.
If the O_NONBLOCK flag is set using fcntl() (defined in <sys/fcntl.h> and explained in fcntl(2)
and fcntl(5)), POSIX-style nonblocking I/O is enabled. In this case, the
send() request completes in one
of three ways:
If there is enough space available in the system to buffer all of the data, send() completes suc-
cessfully, 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 suc-
cessfully, 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, having written no
data, and returns 1, with errno set to [EAGAIN].
HP-UX 11i Version 1: September 2005 2 Hewlett-Packard Company Section 2317