Returns the remote address to which the socket is connected to.
sock_addr_peer() function retrieves the remote address to which the socket identified by the file descriptor
sock is connected and stores the address in the
ro_addr memory location.
;;; either IP4 or IP6. ;;; When successful, the contents of the output buffer consist of an IP address, ;;; ;;; Note: This is similar to `getpeername` in POSIX ;;; ;;; Returns the remote address to which the socket is connected to. (@interface func (export "sock_addr_peer") ;;; Socket that the address is bound to (param $fd $fd) (result $error (expected $addr_port (error $errno))) )
ctx: A mutable reference to the function environment.
sock: The file descriptor of the socket.
ro_addr: A WebAssembly pointer to a memory location where the remote address will be stored.
The function returns an
Errno value indicating the outcome of the operation. If the operation is successful,
Errno::Success is returned. If an error occurs, an appropriate
Errno value is returned.
sock_addr_peer()function retrieves the remote address to which the socket identified by the file descriptor
- The remote address consists of an IP address (either IPv4 or IPv6) and a port number.
- The remote address is stored in the
ro_addrmemory location, which should be a
WasmPtr<__wasi_addr_port_t>pointing to a writable memory region.
- The function
sock_addr_peer()is similar to the
getpeernamefunction in POSIX.
- The behavior and limitations of the
sock_addr_peer()function may vary depending on the specific runtime environment and underlying networking implementation. It is important to consult the documentation or specifications of the specific environment to understand its behavior in that context.