send.2 (2010 09)
s
send(2) send(2)
socklen_t msg_namelen; /* size of address */
struct iovec *msg_iov; /* scatter array for data */
int msg_iovlen; /* # of elements in msg_iov */
void *msg_control; /* ancillary data, see below */
socklen_t msg_controllen; /* ancillary data buffer len */
int msg_flags; /* flags on received message */
}
Obsolescent (UNIX 95)
struct msghdr {
void *msg_name; /* optional address */
size_t msg_namelen; /* size of address */
struct iovec *msg_iov; /* scatter array for data */
int msg_iovlen; /* # of elements in msg_iov */
void *msg_control; /* ancillary data, see below */
size_t msg_controllen; /* ancillary data buffer len */
int msg_flags; /* flags on received message */
}
msg_control specifies a buffer of ancillary data to send along with the message. Ancillary data consists of
a sequence of pairs, each consisting of a cmsghdr structure followed by a data array. The data array con-
tains the ancillary data message, and the cmsghdr structure contains descriptive information that allows
an application to correctly parse the data. cmsghdr has the following structure:
(UNIX 03)
struct cmsghdr {
socklen_t cmsg_len; /* data byte count, including hdr*/
int cmsg_level; /* originating protocol */
int cmsg_type; /* protocol-specific type */
}
Obsolescent (UNIX 95)
struct cmsghdr {
size_t cmsg_len; /* data byte count, including hdr*/
int cmsg_level; /* originating protocol */
int cmsg_type; /* protocol-specific type */
}
If the cmsg_level is SOL_SOCKET, and cmsg_type is SCM_RIGHTS, then it indicates that the data array
contains the access rights to be sent. Access rights are supported only for AF_UNIX. Access rights are
limited to file descriptors of size int .
If the cmsg_level is
IPPROTO_IPV6, then cmsg_type must be one of the supported types:
IPV6_PKTINFO, IPV6_HOPLIMIT, IPV6_NEXTHOP, IPV6_RTHDR, IPV6_HOPOPTS,
IPV6_DSTOPTS or IPV6_RTHDRDSTOPTS. (See description in ip6 (7P)).
If ancillary data are not being transferred, set the msg_control field to NULL, and set the msg_controllen
field to 0.
The msg_flags member is ignored.
X/Open Sockets Compilation Environment
See xopen_networking(7).
RETURN VALUE
send(), sendmsg(), and sendto() return the following values:
n Successful completion. n is the number of bytes sent.
−1 Failure. errno is set to indicate the error.
ERRORS
If
send(), sendmsg(),orsendto() fails, errno is set to one of the following values.
4 Hewlett-Packard Company − 4 − HP-UX 11i Version 3: September 2010