提交 b4bad799 编写于 作者: Y Yi Huang 提交者: hydai

[Doc] Add `open`,`close`, and `bind` to socket API.

上级 4f9067d9
......@@ -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
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册