sock_status()
Returns the current status of a socket.
Description
The sock_status()
function retrieves the current status of a socket identified by the file descriptor sock
and stores the status in the ret_status
memory location.
Syntax
;;; Returns the current status of a socket
(@interface func (export "sock_status")
(param $fd $fd)
(result $error (expected $sock_status (error $errno)))
)
Parameters
ctx
: A mutable reference to the function environment.sock
: The file descriptor of the socket whose status will be retrieved.ret_status
: A WebAssembly pointer to a memory location where the status of the socket will be stored.
Return Value
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.
Notes
- The
sock_status()
function retrieves the current status of the socket identified by the file descriptorsock
. - The status of the socket is stored in the
ret_status
memory location, which should be aWasmPtr<Sockstatus>
pointing to a writable memory region. - The possible socket status values are:
Opening
: The socket is in the process of opening.Opened
: The socket has been successfully opened.Closed
: The socket has been closed.Failed
: An error occurred while opening or using the socket.
- The behavior and limitations of the
sock_status()
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.