Transmits data to another connected (the intended recipient is known) socket.
SYS_SEND with 4th argument set to 0 is identical to sys_write system call.
Arguments:
1st |
Socket descriptor. |
2nd |
Pointer to a buffer containing the data to send. |
3rd |
Size of the data in the buffer pointed by 2nd argument.
If the message is too long to pass atomically through the underlying protocol, the error -EMSGSIZE is returned, and the message is not transmitted.
When the message does not fit into the send buffer of the socket, SYS_SEND normally blocks, unless the socket has been placed in non-blocking I/O mode. In non-blocking mode it would return -EAGAIN in this case. The sys_select call may be used to determine when it is possible to send more data. |
4th |
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 4th 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 |