sock_send_to()
Send a message on a socket to a specific address.
Description
The sock_send_to()
function is used to send a message on a socket to a specific address. It is similar to the sendto
function in POSIX, but it also supports writing the data from multiple buffers in the manner of writev
.
The function sends a message using the provided scatter/gather vectors to the specified address. The number of bytes transmitted is returned.
Syntax
;;; the data from multiple buffers in the manner of `writev`.
;;; Note: This is similar to `sendto` in POSIX, though it also supports writing
;;; Send a message on a socket to a specific address.
(@interface func (export "sock_send_to")
(param $fd $fd)
;;; List of scatter/gather vectors to which to retrieve data
(param $si_data $ciovec_array)
;;; Message flags.
(param $si_flags $siflags)
;;; Address of the socket to send message to
(param $addr (@witx const_pointer $addr_port))
;;; Number of bytes transmitted.
(result $error (expected $size (error $errno)))
)
Parameters
ctx
: A mutable reference to the function environment.sock
: The file descriptor of the socket to send on.si_data
: A list of scatter/gather vectors containing the data to be sent.si_data_len
: The length of the scatter/gather vector list._si_flags
: Message flags.addr
: The address of the socket to send the message to.ret_data_len
: A pointer to store the number of bytes transmitted.
Return Value
The function returns a Result
containing an Errno
value. If the operation is successful, Errno::Success
is returned. Otherwise, an appropriate Errno
value indicating the error is returned.
Notes
- The
sock_send_to()
function sends a message on a socket to a specific address using the provided scatter/gather vectors. - The function supports writing the data from multiple buffers.
- The
si_data
parameter represents a list of scatter/gather vectors, where each vector contains a buffer and its length. - The
si_data_len
parameter specifies the length of the scatter/gather vector list. - The data to be sent is retrieved from the buffers specified by the scatter/gather vectors.
- The
addr
parameter specifies the address of the socket to send the message to. - The specific behavior of the
sock_send_to()
function may vary depending on the runtime environment and underlying networking implementation.