From b59de1b60571bdfe4fe11e5deb79d7363e13ba9e Mon Sep 17 00:00:00 2001
From: Dan Gohman An opaque resource that represents access to (a subset of) the network.
+This enables context-based security for networking.
+There is no need for this to map 1:1 to a physical network interface. Error codes. In theory, every API can return any error code.
@@ -102,18 +105,20 @@ combined with a couple of errors that are always possible: The connection was forcefully rejected
+ The TCP connection was forcefully rejected
The connection was reset.
+ The TCP connection was reset.
A connection was aborted.
+ A TCP connection was aborted.
The size of a datagram sent to a UDP socket exceeded the maximum
+supported size.
Types
+resource network
enum error-code
record ipv4-socket-address
port
: u16
address
: ipv4-address
port
: u16
sin_port +
sin_addr +
record ipv6-socket-address
port
: u16
flow-info
: u32
address
: ipv6-address
scope-id
: u32
port
: u16
sin6_port +
flow-info
: u32
sin6_flowinfo +
sin6_addr +
scope-id
: u32
sin6_scope_id +
variant ip-socket-address
resource pollable
pollable
epresents a single I/O event which may be ready, or not.[method]pollable.ready: func
Return the readiness of a pollable. This function never blocks.
@@ -305,6 +328,7 @@ being reaedy for I/O.resource udp-socket
A UDP socket handle.
resource incoming-datagram-stream
resource outgoing-datagram-stream
resource error
A resource which represents some error information.
+The only method provided by this resource is to-debug-string
,
+which provides some human-readable information about the error.
In the wasi:io
package, this resource is returned through the
+wasi:io/streams/stream-error
type.
To provide more specific error information, other interfaces may
+provide functions to further "downcast" this error into more specific
+error information. For example, error
s returned in streams derived
+from filesystem types to be described using the filesystem's own
+error-code type, using the function
+wasi:filesystem/types/filesystem-error-code
, which takes a parameter
+borrow<error>
and returns
+option<wasi:filesystem/types/error-code>
.
error
into a more
+concrete type is open.[method]error.to-debug-string: func
Returns a string that is suitable to assist humans in debugging @@ -787,8 +825,21 @@ future operations.
resource input-stream
An input bytestream.
+input-stream
s are non-blocking to the extent practical on underlying
+platforms. I/O operations always return promptly; if fewer bytes are
+promptly available than requested, they return the number of bytes promptly
+available, which could even be zero. To wait for data to be available,
+use the subscribe
function to obtain a pollable
which can be polled
+for using wasi:io/poll
.
resource output-stream
An output bytestream.
+output-stream
s are non-blocking to the extent practical on
+underlying platforms. Except where specified otherwise, I/O operations also
+always return promptly, after the number of bytes that can be written
+promptly, which could even be zero. To wait for the stream to be ready to
+accept data, the subscribe
function to obtain a pollable
which can be
+polled for using wasi:io/poll
.[method]input-stream.read: func
Perform a non-blocking read from the stream.
@@ -1165,7 +1216,7 @@ occured.resource tcp-socket
[method]tcp-socket.start-bind: func
Bind the socket to a specific network on the provided IP address and port.
From 6a7f88354e4a2680ddd8d0f81697c6b970a0555d Mon Sep 17 00:00:00 2001 From: Dan Gohman