SYS_SENDMSG
Transmits a message to another socket. It also allows sending ancillary data (also known as control information). Arguments:
`1st` | Socket descriptor.
`2nd` | A pointer to a properly initialized msghdr structure:
`struc msghdr { .msg_name rd 1 .msg_namelen rd 1 .msg_iov rd 1 .msg_iovlen rd 1 .msg_control rd 1 .msg_controllen rd 1 .msg_flags rd 1 }`
`msghdr members: msg_name` `Pointer to a sockaddr structure specifying the source address if the socket is unconnected`. It may be 0. `msg_namelen` `Size of the structure` pointed by `msg_namelen` `msg_iov` Pointer to an array of iovec structures describe scatter-gather locations, as discussed in sys_readv. `msg_iovlen` `Number of elements in the iovec array.` `msg_control` Pointer to a buffer for other protocol control related messages or miscellaneous ancillary data. `msg_controllen` `Size of the buffer pointed by msg_control.` Upon return this member will contain the length of the control message sequence. `msg_flags` This member is set on return of SYS_RECVMSG. It can contain several flags:
`MSG_EOR` | `Indicates end-of-record; the data returned completed a record (generally used with sockets of type SOCK_SEQPACKET).`
`MSG_TRUNC` | `Indicates that the trailing portion of a datagram was discarded because the datagram was larger than the buffer supplied.`
`MSG_CTRUNC` | `Indicates that some control data were discarded due to lack of space in the buffer for ancillary data.`
`MSG_OOB` | `Is returned to indicate that expedited or out-of-band data were received`
`MSG_ERRQUEUE` | `Indicates that no data was received but an extended error from the socket error queue.`
`3rd` | Flags. This argument is a bitwise-or of zero or more of the following flags:
`MSG_CONFIRM` | `Tell the link layer that forward progress happened: you got a successful reply from the other side. If the link layer doesn't get this it will regularly reprobe the neighbour (e.g. via a unicast ARP). Only valid on SOCK_DGRAM and SOCK_RAW sockets and currently only implemented for IPv4 and IPv6. See man 7 arp for details.`
`MSG_DONTROUTE` | `Don't use a gateway to send out the packet, only send to hosts on directly connected networks. This is usually used only by diagnostic or routing programs. This is only defined for protocol families that route; packet sockets don't.`
`MSG_DONTWAIT` | `Enables non-blocking operation; if the operation would block, EAGAIN is returned (this can also be enabled using the O_NONBLOCK with the F_SETFL sys_fcntl).`
`MSG_EOR` | `Terminates a record (when this notion is supported, as for sockets of type SOCK_SEQPACKET).`
`MSG_MORE` | `The caller has more data to send. This flag is used with TCP sockets to obtain the same effect as the TCP_CORK socket option (see man 7 arp), with the difference that this flag can be set on a per-call basis. This flag is also supported for UDP sockets, and informs the kernel to package all of the data sent in calls with this flag set into a single datagram which is only transmitted when a call is performed that does not specify this flag. (See also the UDP_CORK socket option described in man 7 arp.)`
`MSG_NOSIGNAL` | `Requests not to send SIGPIPE on errors on stream oriented sockets when the other end breaks the connection. The -EPIPE error is still returned.`
`MSG_OOB` | `Sends out-of-band data on sockets that support this notion (e.g. of type SOCK_STREAM); the underlying protocol must also support out-of-band data.`
Return values If the system call succeeds the return value is the number of characters sent. If the system call fails the return value is one of the following errno values (These are some standard errors generated by the socket layer. Additional errors may be generated and returned from the underlying protocol modules.):
`-EACCES` | `(For Unix domain sockets, which are identified by pathname) Write permission is denied on the destination socket file, or search permission is denied for one of the directories the path prefix.`
`-EAGAIN, -EWOULDBLOCK` | `The socket is marked non-blocking and the requested operation would block.`
`-EBADF` | `An invalid descriptor was specified.`
`-ECONNRESET` | `Connection reset by peer.`
`-EDESTADDRREQ` | `The socket is not connection-mode, and no peer address is set.`
`-EFAULT` | `An invalid user space address was specified for a parameter.`
`-EINTR` | `A signal occurred before any data was transmitted.`
`-EINVAL` | `Invalid argument passed.`
`-EISCONN` | `The connection-mode socket was connected already but a recipient was specified. (Now either this error is returned, or the recipient specification is ignored.)`
`-EMSGSIZE` | `The socket type requires that message be sent atomically, and the size of the message to be sent made this impossible.`
`-ENOBUFS` | `The output queue for a network interface was full. This generally indicates that the interface has stopped sending, but may be caused by transient congestion. (Normally, this does not occur in Linux. Packets are just silently dropped when a device queue overflows.)`
`-ENOMEM` | `No memory available.`
`-ENOTCONN, -EPIPE` | `The socket is not connected, and no target has been given.`
`-ENOTSOCK` | `The 1st argument is not a socket.`
`-EOPNOTSUPP` | `Some bit in the 3rd argument is inappropriate for the socket type.`
`-EPIPE` | `The local end has been shut down on a connection oriented socket. In this case the process will also receive a SIGPIPE unless MSG_NOSIGNAL is set.`
Remarks n/a Compatibility n/a