ISocket.send

Sends as many src bytes as possible to the remote.

Note: May raise ESIGPIPE on errors when this socket is stream oriented (e.g. TCP), the other end breaks the connection flags does not contain MSG_NOSIGNAL. If this.suppress_sigpipe is true, MSG_NOSIGNAL will be set in flags automatically.

class ISocket
ssize_t
send
(
const(void)[] src
,
int flags
)

Parameters

src const(void)[]

data to send

flags int

the bitwise OR of zero or more of the following flags:

MSG_CONFIRM (Since Linux 2.3.15) 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 neighbor (e.g., via a unicast ARP). Only valid on SOCK_DGRAM and SOCK_RAW sockets and currently only imple‐ mented for IPv4 and IPv6. See arp(7) 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 (since Linux 2.2) Enables nonblocking operation; if the operation would block, EAGAIN or EWOULDBLOCK is returned (this can also be enabled using the O_NONBLOCK flag with the F_SETFL fcntl(2)).

MSG_EOR (since Linux 2.2) Terminates a record (when this notion is supported, as for sockets of type SOCK_SEQPACKET).

MSG_MORE (Since Linux 2.4.4) 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 tcp(7)), with the difference that this flag can be set on a per-call basis.

Since Linux 2.6, 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 data‐ gram which is only transmitted when a call is performed that does not specify this flag. (See also the UDP_CORK socket option described in udp(7).)

MSG_NOSIGNAL (since Linux 2.2) 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 proto‐ col must also support out-of-band data.

Return Value

Type: ssize_t

the number of src bytes sent on success or -1 on failure. On failure errno is set appropriately.

Errors: These are some standard errors generated by the socket layer. Addi‐ tional errors may be generated and returned from the underlying pro‐ tocol modules; see their respective manual pages.

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. (See path_resolution(7).)

EAGAIN or EWOULDBLOCK The socket is marked nonblocking and the requested operation would block. POSIX.1-2001 allows either error to be returned for this case, and does not require these constants to have the same value, so a portable application should check for both possibilities.

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 an argument.

EINTR A signal occurred before any data was transmitted; see sig‐ nal(7).

EINVAL Invalid argument passed.

EISCONN The connection-mode socket was connected already but a recip‐ ient 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 gen‐ erally 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 The socket is not connected, and no target has been given.

ENOTSOCK The argument sockfd is not a socket.

EOPNOTSUPP Some bit in the flags 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.

Meta