Receive a message and its peer address from a socket.
sock_recv_from() function is used to receive a message and its peer address from a socket. It is similar to the
recvfrom function in POSIX, but it also supports reading the data into multiple buffers in the manner of
The function receives data from the socket and stores it in the provided scatter/gather vectors. It also retrieves the peer address from which the message was received. The number of bytes stored in
ri_data, the message flags, and the peer address are returned.
;;; the data into multiple buffers in the manner of `readv`. ;;; Note: This is similar to `recvfrom` in POSIX, though it also supports reading ;;; Receive a message and its peer address from a socket. (@interface func (export "sock_recv_from") (param $fd $fd) ;;; List of scatter/gather vectors to which to store data. (param $ri_data $iovec_array) ;;; Message flags. (param $ri_flags $riflags) ;;; Number of bytes stored in ri_data and message flags. (result $error (expected (tuple $size $roflags $addr_port) (error $errno))) )
ctx: A mutable reference to the function environment.
sock: The file descriptor of the socket to receive from.
ri_data: A list of scatter/gather vectors to which the received data will be stored.
ri_data_len: The length of the scatter/gather vector list.
_ri_flags: Message flags.
ro_data_len: A pointer to store the number of bytes read.
ro_flags: A pointer to store the message flags.
ro_addr: A pointer to store the peer address.
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.
sock_recv_from()function receives a message from a socket and stores it in the provided scatter/gather vectors.
- The function supports reading the data into multiple buffers.
ri_dataparameter represents a list of scatter/gather vectors, where each vector contains a buffer and its length.
ri_data_lenparameter specifies the length of the scatter/gather vector list.
- The received data is stored in the buffers specified by the scatter/gather vectors.
- The number of bytes read from the socket is stored in
- The message flags are stored in
- The peer address from which the message was received is stored in
- The specific behavior of the
sock_recv_from()function may vary depending on the runtime environment and underlying networking implementation.