Sends gathered bytes through a socket to any other socket.
#include <socket.h> int sendmsg (int s, struct msghdr msg[], int flags);Routine Variants This socket routine has a variant named __bsd44_sendmsg. Enabled by defining _SOCKADDR_LEN, this variant implements 4.4BSD-compatible semantics. See Section A.7 for more information.
The msg_iov field of the msghdr structure is used as a series of buffers from which data is read in order until msg_iovlen bytes have been obtained.
If there is no space available to buffer the data being sent on the receiving end of the connection, sendmsg will normally block until buffer space becomes available. If the socket is defined as nonblocking, however, sendmsg will fail with an errno indication of EWOULDBLOCK. If the message is too large to be sent in one piece and the socket type requires that messages be sent atomically (SOCK_ DGRAM), sendmsg will fail with an errno indication of EMSGSIZE.
If the address specified is a INADDR_BROADCAST address, then the SO_BROADCAST option must be set and the process must have SYSPRV or BYPASS privilege for the I/O operation to succeed.
No indication of failure to deliver is implicit in a sendmsg. All errors (except EWOULDBLOCK) are detected locally. You may use the select routine to determine when it is possible to send more data.
See also read, recv, recvfrom, recvmsg, and socket in this section, and getsockopt in this appendix.
n | The number of bytes sent. |
-1 | Indicates an error; errno is set to
one of the following:
|