fn sendto(sockfd: socket_t, buf: []const u8, flags: u32, dest_addr: ?*const sockaddr, addrlen: socklen_t) SendToError!usize

Transmit a message to another socket.

The sendto call may be used only when the socket is in a connected state (so that the intended recipient is known). The following call

 send(sockfd, buf, len, flags);

is equivalent to

 sendto(sockfd, buf, len, flags, NULL, 0);

If sendto() is used on a connection-mode (SOCK.STREAM, SOCK.SEQPACKET) socket, the arguments dest_addr and addrlen are asserted to be null and 0 respectively, and asserted that the socket was actually connected. Otherwise, the address of the target is given by dest_addr with addrlen specifying its size.

If the message is too long to pass atomically through the underlying protocol, SendError.MessageTooBig is returned, and the message is not transmitted.

There is no indication of failure to deliver.

When the message does not fit into the send buffer of the socket, sendto normally blocks, unless the socket has been placed in nonblocking I/O mode. In nonblocking mode it would fail with SendError.WouldBlock. The select call may be used to determine when it is possible to send more data.

Parameters

sockfd: socket_t,

The file descriptor of the sending socket.

buf: []const u8,

Message to send.

flags: u32,
dest_addr: ?*const sockaddr,
addrlen: socklen_t,