From df2e6d3de2eba9187c3e791429687e8e02b6b551 Mon Sep 17 00:00:00 2001
From: Dave Bakker
-
-
wasi:sockets/network
wasi:sockets/instance-network
wasi:io/poll
wasi:sockets/udp
wasi:sockets/udp-create-socket
wasi:io/streams
wasi:sockets/tcp
wasi:sockets/tcp-create-socket
wasi:sockets/ip-name-lookup
wasi:sockets/network@0.2.0-rc-2023-11-10
wasi:sockets/instance-network@0.2.0-rc-2023-11-10
wasi:io/poll@0.2.0-rc-2023-11-10
wasi:sockets/udp@0.2.0-rc-2023-11-10
wasi:sockets/udp-create-socket@0.2.0-rc-2023-11-10
wasi:io/error@0.2.0-rc-2023-11-10
wasi:io/streams@0.2.0-rc-2023-11-10
wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10
wasi:sockets/tcp@0.2.0-rc-2023-11-10
wasi:sockets/tcp-create-socket@0.2.0-rc-2023-11-10
wasi:sockets/ip-name-lookup@0.2.0-rc-2023-11-10
Import interface wasi:sockets/network
+Import interface wasi:sockets/network@0.2.0-rc-2023-11-10
Types
@@ -184,7 +186,7 @@ combined with a couple of errors that are always possible:resource network
ipv4
: ipv4-socket-address
ipv6
: ipv6-socket-address
This interface provides a value-export of the default network handle..
network
>A poll API intended to let users wait for I/O events on multiple handles at once.
type pollable
address
is unspecified.
[method]udp-socket.unicast-hop-limit: func
Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.
+If the provided value is 0, an invalid-argument
error is returned.
invalid-argument
: (set) The TTL value must be 1 or higher.self
: borrow<udp-socket
>address
is unspecified.
[method]udp-socket.receive-buffer-size: func
The kernel buffer space reserved for sends/receives on this socket.
-Note #1: an implementation may choose to cap or round the buffer size when setting the value. -In other words, after setting a value, reading the same setting back may return a different value.
-Note #2: there is not necessarily a direct relationship between the kernel buffer size and the bytes of -actual data to be sent/received by the application, because the kernel might also use the buffer space -for internal metadata structures.
+If the provided value is 0, an invalid-argument
error is returned.
+Any other value will never cause an error, but it might be silently clamped and/or rounded.
+I.e. after setting a value, reading the same setting back may return a different value.
Equivalent to the SO_RCVBUF and SO_SNDBUF socket options.
+invalid-argument
: (set) The provided value was 0.self
: borrow<udp-socket
>future
is natively supported in Pre
pollable
>type network
udp-socket
>, error-code
>resource error
[method]error.to-debug-string: func
Returns a string that is suitable to assist humans in debugging +this error.
+WARNING: The returned string should not be consumed mechanically! +It may change across platforms, hosts, or other implementation +details. Parsing this string is a major platform-compatibility +hazard.
+WASI I/O is an I/O abstraction API which is currently focused on providing stream types.
In the future, the component model is expected to add built-in stream types; when it does, they are expected to subsume this API.
type pollable
type error
-#### `resource error` -
variant stream-error
+#### `variant stream-error`
An error for input-stream and output-stream operations.
resource output-stream
[method]error.to-debug-string: func
Returns a string that's suitable to assist humans in debugging this -error.
-The returned string will change across platforms and hosts which -means that parsing it, for example, would be a -platform-compatibility hazard.
-[method]input-stream.read: func
Perform a non-blocking read from the stream.
This function returns a list of bytes containing the read data,
@@ -1042,7 +1060,68 @@ is ready for reading, before performing the splice
.
u64
, stream-error
>WASI Monotonic Clock is a clock API intended to let users measure elapsed +time.
+It is intended to be portable at least between Unix-family platforms and +Windows.
+A monotonic clock is a clock which has an unspecified initial value, and +successive reads of the clock will produce non-decreasing values.
+It is intended for measuring elapsed time.
+type pollable
+#### `type instant` +`u64` +
An instant in time, in nanoseconds. An instant is relative to an +unspecified initial value, and can only be compared to instances from +the same monotonic-clock. +
type duration
u64
A duration of time, in nanoseconds. +
now: func
Read the current value of the clock.
+The clock is monotonic, therefore calling this function repeatedly will +produce a sequence of non-decreasing values.
+instant
resolution: func
Query the resolution of the clock. Returns the duration of time +corresponding to a clock tick.
+duration
subscribe-instant: func
Create a pollable
which will resolve once the specified instant
+occured.
pollable
>subscribe-duration: func
Create a pollable
which will resolve once the given duration has
+elapsed, starting at the time at which this function was called.
+occured.
pollable
>type input-stream
splice
.
#### `type pollable`
[`pollable`](#pollable)
+#### `type duration` +[`duration`](#duration) +
#### `type network` [`network`](#network)
@@ -1251,8 +1333,11 @@ Besides drop
, any method after such a failure may return an error.<
address-family
ipv6-only
keep-alive
unicast-hop-limit
keep-alive-enabled
keep-alive-idle-time
keep-alive-interval
keep-alive-count
hop-limit
receive-buffer-size
send-buffer-size
address
is unspecified.
ip-socket-address
, error-code
>[method]tcp-socket.is-listening: func
Whether the socket is listening for new connections.
+Equivalent to the SO_ACCEPTCONN socket option.
+self
: borrow<tcp-socket
>[method]tcp-socket.address-family: func
Whether this is a IPv4 or IPv6 socket.
Equivalent to the SO_DOMAIN socket option.
@@ -1368,9 +1464,12 @@ stored in the object pointed to byaddress
is unspecified.
[method]tcp-socket.set-listen-backlog-size: func
Hints the desired listen queue size. Implementations are free to ignore this.
+If the provided value is 0, an invalid-argument
error is returned.
+Any other value will never cause an error, but it might be silently clamped and/or rounded.
not-supported
: (set) The platform does not support changing the backlog size after the initial listen.invalid-argument
: (set) The provided value was 0.invalid-state
: (set) The socket is already in the Connection state.address
is unspecified.
error-code
>[method]tcp-socket.keep-alive: func
[method]tcp-socket.keep-alive-enabled: func
Enables or disables keepalive.
+The keepalive behavior can be adjusted using:
+keep-alive-idle-time
keep-alive-interval
keep-alive-count
+These properties can be configured while keep-alive-enabled
is false, but only come into effect when keep-alive-enabled
is true.Equivalent to the SO_KEEPALIVE socket option.
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>bool
, error-code
>[method]tcp-socket.set-keep-alive-enabled: func
self
: borrow<tcp-socket
>value
: bool
error-code
>[method]tcp-socket.keep-alive-idle-time: func
Amount of time the connection has to be idle before TCP starts sending keepalive packets.
+If the provided value is 0, an invalid-argument
error is returned.
+Any other value will never cause an error, but it might be silently clamped and/or rounded.
+I.e. after setting a value, reading the same setting back may return a different value.
Equivalent to the TCP_KEEPIDLE socket option. (TCP_KEEPALIVE on MacOS)
+invalid-argument
: (set) The provided value was 0.self
: borrow<tcp-socket
>duration
, error-code
>[method]tcp-socket.set-keep-alive-idle-time: func
self
: borrow<tcp-socket
>value
: duration
error-code
>[method]tcp-socket.keep-alive-interval: func
The time between keepalive packets.
+If the provided value is 0, an invalid-argument
error is returned.
+Any other value will never cause an error, but it might be silently clamped and/or rounded.
+I.e. after setting a value, reading the same setting back may return a different value.
Equivalent to the TCP_KEEPINTVL socket option.
+invalid-argument
: (set) The provided value was 0.self
: borrow<tcp-socket
>duration
, error-code
>[method]tcp-socket.set-keep-alive-interval: func
self
: borrow<tcp-socket
>value
: duration
error-code
>[method]tcp-socket.keep-alive-count: func
The maximum amount of keepalive packets TCP should send before aborting the connection.
+If the provided value is 0, an invalid-argument
error is returned.
+Any other value will never cause an error, but it might be silently clamped and/or rounded.
+I.e. after setting a value, reading the same setting back may return a different value.
Equivalent to the TCP_KEEPCNT socket option.
+invalid-argument
: (set) The provided value was 0.self
: borrow<tcp-socket
>bool
, error-code
>u32
, error-code
>[method]tcp-socket.set-keep-alive: func
[method]tcp-socket.set-keep-alive-count: func
self
: borrow<tcp-socket
>value
: bool
self
: borrow<tcp-socket
>value
: u32
error-code
>error-code
>[method]tcp-socket.unicast-hop-limit: func
[method]tcp-socket.hop-limit: func
Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.
+If the provided value is 0, an invalid-argument
error is returned.
invalid-argument
: (set) The TTL value must be 1 or higher.address
is unspecified.
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>u8
, error-code
>u8
, error-code
>[method]tcp-socket.set-unicast-hop-limit: func
[method]tcp-socket.set-hop-limit: func
self
: borrow<tcp-socket
>value
: u8
self
: borrow<tcp-socket
>value
: u8
error-code
>error-code
>[method]tcp-socket.receive-buffer-size: func
The kernel buffer space reserved for sends/receives on this socket.
-Note #1: an implementation may choose to cap or round the buffer size when setting the value. -In other words, after setting a value, reading the same setting back may return a different value.
-Note #2: there is not necessarily a direct relationship between the kernel buffer size and the bytes of -actual data to be sent/received by the application, because the kernel might also use the buffer space -for internal metadata structures.
+If the provided value is 0, an invalid-argument
error is returned.
+Any other value will never cause an error, but it might be silently clamped and/or rounded.
+I.e. after setting a value, reading the same setting back may return a different value.
Equivalent to the SO_RCVBUF and SO_SNDBUF socket options.
invalid-argument
: (set) The provided value was 0.invalid-state
: (set) The socket is already in the Connection state.invalid-state
: (set) The socket is already in the Listener state.output-stream
associ
error-code
>type network
tcp-socket
>, error-code
>type pollable