diff --git a/doc/witx/typenames.witx b/doc/witx/typenames.witx index bc2c4464c11384c46336b529b5260ffe1d380fde..0ab2ad224278ad3b96b722836d1f8b496293ecd1 100644 --- a/doc/witx/typenames.witx +++ b/doc/witx/typenames.witx @@ -278,6 +278,12 @@ ;;; If `rights::fd_read` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_read`. ;;; If `rights::fd_write` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_write`. $poll_fd_readwrite + ;;; The right to invoke `sock_open`. + $sock_open + ;;; The right to invoke `sock_close`. + $sock_close + ;;; The right to invoke `sock_bind`. + $sock_bind ;;; The right to invoke `sock_recv`. $sock_recv ;;; The right to invoke `sock_recv_from`. @@ -653,6 +659,22 @@ ;;; Exit code generated by a process when exiting. (typename $exitcode u32) +;;; Socket address family +(typename $address_family + (enum u8 + $inet4 + $inet6 + ) +) + +;;; Socket type +(typename $sock_type + (enum u8 + $sock_dgram + $sock_stream + ) +) + ;;; Flags provided to `sock_recv`. (typename $riflags (flags u16 diff --git a/doc/witx/wasi_ephemeral_sock.witx b/doc/witx/wasi_ephemeral_sock.witx index 5266a9d6f477de4c324f70029171b082ef6155df..2caf9dca98734d5d6d17b34a65ba2f6cbfc08c0a 100644 --- a/doc/witx/wasi_ephemeral_sock.witx +++ b/doc/witx/wasi_ephemeral_sock.witx @@ -13,6 +13,36 @@ ;;; Linear memory to be accessed by WASI functions that need it. (import "memory" (memory)) + ;;; Open a socket. + ;;; Note: This is similar to `socket` with `PF_INET` in POSIX. + (@interface func (export "open") + ;;; Some descriptor. + ;;; TODO: Describe more about the capability for the descriptor? + (param $capability $fd) + (param $af $address_family) + (param $socktype $sock_type) + (result $error $errno) + (result $fd $fd) + ) + + ;;; Close a socket. + ;;; Note: This is currently an alias for `fd_close`. + ;;; Note: This is similar to `close` in POSIX. + (@interface func (export "close") + (param $fd $fd) + (result $error $errno) + ) + + ;;; Bind a name to a socket. + ;;; Note: This is similar to `bind` in POSIX. + (@interface func (export "bind") + (param $fd $fd) + ;;; The pointer to and length of the buffer for address. + (param $addr_buf (@witx pointer u8)) + (param $addr_buf_len $size) + (result $error $errno) + ) + ;;; Receive a message from a socket. ;;; Note: This is similar to `recv` in POSIX. ;;; Note: This is identical to `recvfrom` with a null pointer passed as its