From 7072889b0d9f77449f261c9f76536b242d1de0b8 Mon Sep 17 00:00:00 2001
From: Yosh
type pollable
type pollable
-#### `type network` +#### `type network` [`network`](#network)
-#### `type error-code` +#### `type error-code` [`error-code`](#error_code)
-#### `type ip-socket-address` +#### `type ip-socket-address` [`ip-socket-address`](#ip_socket_address)
-#### `type ip-address-family` +#### `type ip-address-family` [`ip-address-family`](#ip_address_family)
-#### `record incoming-datagram` +#### `record incoming-datagram`
A received datagram.
data
: list<u8
>
The payload.
Theoretical max size: ~64 KiB. In practice, typically less than 1500 bytes.
remote-address
: ip-socket-address
remote-address
: ip-socket-address
The source address.
This field is guaranteed to match the remote address the stream was initialized with, if any.
Equivalent to the src_addr
out parameter of recvfrom
.
record outgoing-datagram
record outgoing-datagram
A datagram to be sent out.
data
: list<u8
>
The payload.
remote-address
: option<ip-socket-address
>
remote-address
: option<ip-socket-address
>
The destination address.
The requirements on this field depend on how the stream was initialized:
If this value is None, the send operation is equivalent to send
in POSIX. Otherwise it is equivalent to sendto
.
resource udp-socket
resource udp-socket
A UDP socket handle.
-resource incoming-datagram-stream
resource outgoing-datagram-stream
resource incoming-datagram-stream
resource outgoing-datagram-stream
[method]udp-socket.start-bind: func
[method]udp-socket.start-bind: func
Bind the socket to a specific network on the provided IP address and port.
If the IP address is zero (0.0.0.0
in IPv4, ::
in IPv6), it is left to the implementation to decide which
network interface(s) to bind to.
@@ -362,24 +362,24 @@ don't want to make use of this ability can simply call the native
self
: borrow<udp-socket
>network
: borrow<network
>local-address
: ip-socket-address
self
: borrow<udp-socket
>network
: borrow<network
>local-address
: ip-socket-address
error-code
>error-code
>[method]udp-socket.finish-bind: func
[method]udp-socket.finish-bind: func
self
: borrow<udp-socket
>self
: borrow<udp-socket
>error-code
>error-code
>[method]udp-socket.stream: func
[method]udp-socket.stream: func
Set up inbound & outbound communication channels, optionally to a specific peer.
This function only changes the local socket configuration and does not generate any network traffic.
On success, the remote-address
of the socket is updated. The local-address
may be updated as well,
@@ -420,14 +420,14 @@ if (remote_address is Some) {
self
: borrow<udp-socket
>remote-address
: option<ip-socket-address
>self
: borrow<udp-socket
>remote-address
: option<ip-socket-address
>incoming-datagram-stream
>, own<outgoing-datagram-stream
>), error-code
>incoming-datagram-stream
>, own<outgoing-datagram-stream
>), error-code
>[method]udp-socket.local-address: func
[method]udp-socket.local-address: func
Get the current bound address.
POSIX mentions:
@@ -448,13 +448,13 @@ stored in the object pointed to byaddress
is unspecified.Params
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>Return values
-
-- result<
+ip-socket-address
,error-code
>- result<
ip-socket-address
,error-code
>+
[method]udp-socket.remote-address: func
[method]udp-socket.remote-address: func
Get the address the socket is currently streaming to.
Typical errors
@@ -469,24 +469,24 @@ stored in the object pointed to by
address
is unspecified.Params
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>Return values
-
-- result<
+ip-socket-address
,error-code
>- result<
ip-socket-address
,error-code
>+
[method]udp-socket.address-family: func
[method]udp-socket.address-family: func
Whether this is a IPv4 or IPv6 socket.
Equivalent to the SO_DOMAIN socket option.
Params
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>Return values
-+
[method]udp-socket.unicast-hop-limit: func
[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.Typical errors
@@ -495,23 +495,23 @@ stored in the object pointed to byaddress
is unspecified.Params
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>Return values
-
-- result<
+u8
,error-code
>- result<
u8
,error-code
>+
[method]udp-socket.set-unicast-hop-limit: func
[method]udp-socket.set-unicast-hop-limit: func
Params
-
- -
self
: borrow<udp-socket
>- +
value
:u8
- +
self
: borrow<udp-socket
>value
:u8
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]udp-socket.receive-buffer-size: func
[method]udp-socket.receive-buffer-size: func
The kernel buffer space reserved for sends/receives on this socket.
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. @@ -523,54 +523,54 @@ I.e. after setting a value, reading the same setting back may return a differentParams
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>Return values
-
-- result<
+u64
,error-code
>- result<
u64
,error-code
>+
[method]udp-socket.set-receive-buffer-size: func
[method]udp-socket.set-receive-buffer-size: func
Params
-
- -
self
: borrow<udp-socket
>- +
value
:u64
- +
self
: borrow<udp-socket
>value
:u64
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]udp-socket.send-buffer-size: func
[method]udp-socket.send-buffer-size: func
Params
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>Return values
-
-- result<
+u64
,error-code
>- result<
u64
,error-code
>+
[method]udp-socket.set-send-buffer-size: func
[method]udp-socket.set-send-buffer-size: func
Params
-
- -
self
: borrow<udp-socket
>- +
value
:u64
- +
self
: borrow<udp-socket
>value
:u64
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]udp-socket.subscribe: func
[method]udp-socket.subscribe: func
Create a
pollable
which will resolve once the socket is ready for I/O.Note: this function is here for WASI Preview2 only. It's planned to be removed when
future
is natively supported in Preview3.Params
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>Return values
-+
[method]incoming-datagram-stream.receive: func
[method]incoming-datagram-stream.receive: func
Receive messages on the socket.
This function attempts to receive up to
@@ -598,26 +598,26 @@ This function never returnsmax-results
datagrams on the socket without blocking. The returned list may contain fewer elements than requested, but never more.error(would-block)
.Params
-
- -
self
: borrow<incoming-datagram-stream
>- +
max-results
:u64
- +
self
: borrow<incoming-datagram-stream
>max-results
:u64
Return values
-
-- result<list<
+incoming-datagram
>,error-code
>- result<list<
incoming-datagram
>,error-code
>+
[method]incoming-datagram-stream.subscribe: func
[method]incoming-datagram-stream.subscribe: func
Create a
pollable
which will resolve once the stream is ready to receive again.Note: this function is here for WASI Preview2 only. It's planned to be removed when
future
is natively supported in Preview3.Params
-
- +
self
: borrow<incoming-datagram-stream
>self
: borrow<incoming-datagram-stream
>Return values
-+
[method]outgoing-datagram-stream.check-send: func
[method]outgoing-datagram-stream.check-send: func
Check readiness for sending. This function never blocks.
Returns the number of datagrams permitted for the next call to
send
, or an error. Callingsend
with more datagrams than this function has @@ -628,13 +628,13 @@ error.Never returns
would-block
.Params
-
- +
self
: borrow<outgoing-datagram-stream
>self
: borrow<outgoing-datagram-stream
>Return values
-
-- result<
+u64
,error-code
>- result<
u64
,error-code
>+
[method]outgoing-datagram-stream.send: func
[method]outgoing-datagram-stream.send: func
Send messages on the socket.
This function attempts to send all provided
datagrams
on the socket without blocking and returns how many messages were actually sent (or queued for sending). This function never @@ -669,43 +669,43 @@ eithercheck-send
was not called ordatagrams
containsParams
-
- -
self
: borrow<outgoing-datagram-stream
>- +
datagrams
: list<outgoing-datagram
>- +
self
: borrow<outgoing-datagram-stream
>datagrams
: list<outgoing-datagram
>Return values
-
-- result<
+u64
,error-code
>- result<
u64
,error-code
>+
[method]outgoing-datagram-stream.subscribe: func
[method]outgoing-datagram-stream.subscribe: func
Create a
pollable
which will resolve once the stream is ready to send again.Note: this function is here for WASI Preview2 only. It's planned to be removed when
future
is natively supported in Preview3.Params
-
- +
self
: borrow<outgoing-datagram-stream
>self
: borrow<outgoing-datagram-stream
>Return values
-Import interface wasi:sockets/udp-create-socket@0.2.0
+Import interface wasi:sockets/udp-create-socket@0.2.0
Types
-+
type network
type network
-#### `type error-code` +#### `type error-code` [`error-code`](#error_code)
-#### `type ip-address-family` +#### `type ip-address-family` [`ip-address-family`](#ip_address_family)
-#### `type udp-socket` +#### `type udp-socket` [`udp-socket`](#udp_socket)
----
Functions
-+
create-udp-socket: func
create-udp-socket: func
Create a new UDP socket.
Similar to
@@ -727,16 +727,16 @@ the socket is effectively an in-memory configuration object, unable to communicasocket(AF_INET or AF_INET6, SOCK_DGRAM, IPPROTO_UDP)
in POSIX. On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise.Params
-
- +
address-family
:ip-address-family
address-family
:ip-address-family
Return values
-
- result<own<
udp-socket
>,error-code
>Import interface wasi:io/error@0.2.0
+Import interface wasi:io/error@0.2.0
Types
-+
resource error
resource error
A resource which represents some error information.
The only method provided by this resource is
@@ -753,7 +753,7 @@ error-code type, using the functionto-debug-string
, which provides some human-readable information about the error.The set of functions which can "downcast" an
error
into a more concrete type is open.Functions
-+
[method]error.to-debug-string: func
[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! @@ -762,42 +762,42 @@ details. Parsing this string is a major platform-compatibility hazard.
Params
Return values
-Import interface wasi:io/streams@0.2.0
+Import interface wasi:io/streams@0.2.0
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.
Types
-+
type error
type error
-#### `type pollable` +#### `type pollable` [`pollable`](#pollable)
-#### `variant stream-error` +#### `variant stream-error`
An error for input-stream and output-stream operations.
Variant Cases
-
- -
+
last-operation-failed
: own<error
>
last-operation-failed
: own<error
>The last operation (a write or flush) failed before completion.
More information is available in the
error
payload.- - +
The stream is closed: no more input will be accepted by the stream. A closed output-stream will return this error on all future operations.
+
resource input-stream
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 @@ -805,7 +805,7 @@ 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 thesubscribe
function to obtain apollable
which can be polled for usingwasi:io/poll
.+
resource output-stream
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 @@ -814,7 +814,7 @@ promptly, which could even be zero. To wait for the stream to be ready to accept data, thesubscribe
function to obtain apollable
which can be polled for usingwasi:io/poll
.Functions
-+
[method]input-stream.read: func
[method]input-stream.read: func
Perform a non-blocking read from the stream.
When the source of a
read
is binary data, the bytes from the source are returned verbatim. When the source of aread
is known to the @@ -838,51 +838,51 @@ as a return value by the callee. The callee may return a list of bytes less thanlen
in size while more bytes are available for reading.Params
-
- -
self
: borrow<input-stream
>- +
len
:u64
- +
self
: borrow<input-stream
>len
:u64
Return values
-
-- result<list<
+u8
>,stream-error
>- result<list<
u8
>,stream-error
>+
[method]input-stream.blocking-read: func
[method]input-stream.blocking-read: func
Read bytes from a stream, after blocking until at least one byte can be read. Except for blocking, behavior is identical to
read
.Params
-
- -
self
: borrow<input-stream
>- +
len
:u64
- +
self
: borrow<input-stream
>len
:u64
Return values
-
-- result<list<
+u8
>,stream-error
>- result<list<
u8
>,stream-error
>+
[method]input-stream.skip: func
[method]input-stream.skip: func
Skip bytes from a stream. Returns number of bytes skipped.
Behaves identical to
read
, except instead of returning a list of bytes, returns the number of bytes consumed from the stream.Params
-
- -
self
: borrow<input-stream
>- +
len
:u64
- +
self
: borrow<input-stream
>len
:u64
Return values
-
-- result<
+u64
,stream-error
>- result<
u64
,stream-error
>+
[method]input-stream.blocking-skip: func
[method]input-stream.blocking-skip: func
Skip bytes from a stream, after blocking until at least one byte can be skipped. Except for blocking behavior, identical to
skip
.Params
-
- -
self
: borrow<input-stream
>- +
len
:u64
- +
self
: borrow<input-stream
>len
:u64
Return values
-
-- result<
+u64
,stream-error
>- result<
u64
,stream-error
>+
[method]input-stream.subscribe: func
[method]input-stream.subscribe: func
Create a
pollable
which will resolve once either the specified stream has bytes available to read or the other end of the stream has been closed. @@ -891,13 +891,13 @@ Implementations may trap if theinput-stream
pollable
s created with this function are dropped.Params
-
- +
self
: borrow<input-stream
>self
: borrow<input-stream
>Return values
-+
[method]output-stream.check-write: func
[method]output-stream.check-write: func
Check readiness for writing. This function never blocks.
Returns the number of bytes permitted for the next call to
write
, or an error. Callingwrite
with more bytes than this function has @@ -907,13 +907,13 @@ become ready when this function will report at least 1 byte, or an error.Params
-
- +
self
: borrow<output-stream
>self
: borrow<output-stream
>Return values
-
-- result<
+u64
,stream-error
>- result<
u64
,stream-error
>+
[method]output-stream.write: func
[method]output-stream.write: func
Perform a write. This function never blocks.
When the destination of a
the last call to check-write provided a permit.write
is binary data, the bytes fromcontents
are written verbatim. When the destination of awrite
is @@ -926,14 +926,14 @@ length of less than or equal to n. Otherwise, this function will trap.Params
-
- -
self
: borrow<output-stream
>- +
contents
: list<u8
>- +
self
: borrow<output-stream
>contents
: list<u8
>Return values
-
-- result<_,
+stream-error
>- result<_,
stream-error
>+
[method]output-stream.blocking-write-and-flush: func
[method]output-stream.blocking-write-and-flush: func
Perform a write of up to 4096 bytes, and then flush the stream. Block until all of these operations are complete, or an error occurs.
This is a convenience wrapper around the use of
check-write
, @@ -957,14 +957,14 @@ let _ = this.check-write(); // eliding error handlingParams
-
- -
self
: borrow<output-stream
>- +
contents
: list<u8
>- +
self
: borrow<output-stream
>contents
: list<u8
>Return values
-
-- result<_,
+stream-error
>- result<_,
stream-error
>+
[method]output-stream.flush: func
[method]output-stream.flush: func
Request to flush buffered output. This function never blocks.
This tells the output-stream that the caller intends any buffered output to be flushed. the output which is expected to be flushed @@ -975,24 +975,24 @@ completed. The
subscribe
pollable will become ready when the flush has completed and the stream can accept more writes.Params
-
- +
self
: borrow<output-stream
>self
: borrow<output-stream
>Return values
-
-- result<_,
+stream-error
>- result<_,
stream-error
>+
[method]output-stream.blocking-flush: func
[method]output-stream.blocking-flush: func
Request to flush buffered output, and block until flush completes and stream is ready for writing again.
Params
-
- +
self
: borrow<output-stream
>self
: borrow<output-stream
>Return values
-
-- result<_,
+stream-error
>- result<_,
stream-error
>+
[method]output-stream.subscribe: func
[method]output-stream.subscribe: func
Create a
pollable
which will resolve once the output-stream is ready for more writing, or an error has occured. When this pollable is ready,check-write
will returnok(n)
with n>0, or an @@ -1003,13 +1003,13 @@ Implementations may trap if theoutput-stream
s created with this function are dropped.pollable
Params
-
- +
self
: borrow<output-stream
>self
: borrow<output-stream
>Return values
-+
[method]output-stream.write-zeroes: func
[method]output-stream.write-zeroes: func
Write zeroes to a stream.
This should be used precisely like
write
with the exact same preconditions (must use check-write first), but instead of @@ -1017,14 +1017,14 @@ passing a list of bytes, you simply pass the number of zero-bytes that should be written.Params
-
- -
self
: borrow<output-stream
>- +
len
:u64
- +
self
: borrow<output-stream
>len
:u64
Return values
-
-- result<_,
+stream-error
>- result<_,
stream-error
>+
[method]output-stream.blocking-write-zeroes-and-flush: func
[method]output-stream.blocking-write-zeroes-and-flush: func
Perform a write of up to 4096 zeroes, and then flush the stream. Block until all of these operations are complete, or an error occurs.
@@ -1048,14 +1048,14 @@ let _ = this.check-write(); // eliding error handlingParams
-
- -
self
: borrow<output-stream
>- +
len
:u64
- +
self
: borrow<output-stream
>len
:u64
Return values
-
-- result<_,
+stream-error
>- result<_,
stream-error
>+
[method]output-stream.splice: func
[method]output-stream.splice: func
Read from one stream and write to another.
The behavior of splice is equivelant to:
@@ -1070,30 +1070,30 @@ let _ = this.check-write(); // eliding error handling than
len
.Params
-
- -
self
: borrow<output-stream
>- -
src
: borrow<input-stream
>- +
len
:u64
- +
self
: borrow<output-stream
>- +
src
: borrow<input-stream
>len
:u64
Return values
-
-- result<
+u64
,stream-error
>- result<
u64
,stream-error
>+
[method]output-stream.blocking-splice: func
[method]output-stream.blocking-splice: func
Read from one stream and write to another, with blocking.
This is similar to
splice
, except that it blocks until theoutput-stream
is ready for writing, and theinput-stream
is ready for reading, before performing thesplice
.Params
-
- -
self
: borrow<output-stream
>- -
src
: borrow<input-stream
>- +
len
:u64
- +
self
: borrow<output-stream
>- +
src
: borrow<input-stream
>len
:u64
Return values
-
-- result<
+u64
,stream-error
>- result<
u64
,stream-error
>Import interface wasi:clocks/monotonic-clock@0.2.0
+Import interface wasi:clocks/monotonic-clock@0.2.0
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 @@ -1103,20 +1103,20 @@ successive reads of the clock will produce non-decreasing values.
It is intended for measuring elapsed time.
Types
-+
type pollable
type pollable
-#### `type instant` +#### `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
type duration
u64
A duration of time, in nanoseconds.
Functions
-+
now: func
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.
@@ -1124,80 +1124,80 @@ produce a sequence of non-decreasing values. -+
resolution: func
resolution: func
Query the resolution of the clock. Returns the duration of time corresponding to a clock tick.
Return values
-+
subscribe-instant: func
subscribe-instant: func
Create a
pollable
which will resolve once the specified instant occured.Params
Return values
-
- own<
pollable
>+
subscribe-duration: func
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.Params
Return values
-
- own<
pollable
>Import interface wasi:sockets/tcp@0.2.0
+Import interface wasi:sockets/tcp@0.2.0
Types
-+
type input-stream
type input-stream
-#### `type output-stream` +#### `type output-stream` [`output-stream`](#output_stream)
-#### `type pollable` +#### `type pollable` [`pollable`](#pollable)
-#### `type duration` +#### `type duration` [`duration`](#duration)
-#### `type network` +#### `type network` [`network`](#network)
-#### `type error-code` +#### `type error-code` [`error-code`](#error_code)
-#### `type ip-socket-address` +#### `type ip-socket-address` [`ip-socket-address`](#ip_socket_address)
-#### `type ip-address-family` +#### `type ip-address-family` [`ip-address-family`](#ip_address_family)
-#### `enum shutdown-type` +#### `enum shutdown-type`
Enum Cases
-
- - +
Similar to `SHUT_RD` in POSIX.
- - +
Similar to `SHUT_WR` in POSIX.
- - +
Similar to `SHUT_RDWR` in POSIX.
+
resource tcp-socket
resource tcp-socket
A TCP socket resource.
The socket can be in one of the following states:
@@ -1219,7 +1219,7 @@ the term "bound" without backticks it actually means: in the
bou
network::error-code
type, TCP socket methods may always returnerror(invalid-state)
when in theclosed
state.Functions
-+
[method]tcp-socket.start-bind: func
[method]tcp-socket.start-bind: func
Bind the socket to a specific network on the provided IP address and port.
If the IP address is zero (
0.0.0.0
in IPv4,::
in IPv6), it is left to the implementation to decide which network interface(s) to bind to. @@ -1258,24 +1258,24 @@ don't want to make use of this ability can simply call the nativeParams
-
- -
self
: borrow<tcp-socket
>- -
network
: borrow<network
>- +
local-address
:ip-socket-address
- +
self
: borrow<tcp-socket
>- +
network
: borrow<network
>local-address
:ip-socket-address
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.finish-bind: func
[method]tcp-socket.finish-bind: func
Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.start-connect: func
[method]tcp-socket.start-connect: func
Connect to a remote endpoint.
On success:
@@ -1320,24 +1320,24 @@ the
SO_ERROR
socket option, in case the poll signaled readiness.Params
-
- -
self
: borrow<tcp-socket
>- -
network
: borrow<network
>- +
remote-address
:ip-socket-address
- +
self
: borrow<tcp-socket
>- +
network
: borrow<network
>remote-address
:ip-socket-address
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.finish-connect: func
[method]tcp-socket.finish-connect: func
Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<(own<
+input-stream
>, own<output-stream
>),error-code
>- result<(own<
input-stream
>, own<output-stream
>),error-code
>+
[method]tcp-socket.start-listen: func
[method]tcp-socket.start-listen: func
Start listening for new connections.
Transitions the socket into the
listening
state.Unlike POSIX, the socket must already be explicitly bound.
@@ -1364,22 +1364,22 @@ don't want to make use of this ability can simply call the nativeParams
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.finish-listen: func
[method]tcp-socket.finish-listen: func
Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.accept: func
[method]tcp-socket.accept: func
Accept a new client socket.
The returned socket is bound and in the
connected
state. The following properties are inherited from the listener socket:@@ -1410,13 +1410,13 @@ a pair of streams that can be used to read & write to the connection.
Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<(own<
+tcp-socket
>, own<input-stream
>, own<output-stream
>),error-code
>- result<(own<
tcp-socket
>, own<input-stream
>, own<output-stream
>),error-code
>+
[method]tcp-socket.local-address: func
[method]tcp-socket.local-address: func
Get the bound local address.
POSIX mentions:
@@ -1437,13 +1437,13 @@ stored in the object pointed to byaddress
is unspecified.Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+ip-socket-address
,error-code
>- result<
ip-socket-address
,error-code
>+
[method]tcp-socket.remote-address: func
[method]tcp-socket.remote-address: func
Get the remote address.
Typical errors
@@ -1458,35 +1458,35 @@ stored in the object pointed to by
address
is unspecified.Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+ip-socket-address
,error-code
>- result<
ip-socket-address
,error-code
>+
[method]tcp-socket.is-listening: func
[method]tcp-socket.is-listening: func
Whether the socket is in the
listening
state.Equivalent to the SO_ACCEPTCONN socket option.
Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-+
[method]tcp-socket.address-family: func
[method]tcp-socket.address-family: func
Whether this is a IPv4 or IPv6 socket.
Equivalent to the SO_DOMAIN socket option.
Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-+
[method]tcp-socket.set-listen-backlog-size: func
[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
@@ -1498,14 +1498,14 @@ Any other value will never cause an error, but it might be silently clamped and/invalid-argument
error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded.Params
-
- -
self
: borrow<tcp-socket
>- +
value
:u64
- +
self
: borrow<tcp-socket
>value
:u64
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.keep-alive-enabled: func
[method]tcp-socket.keep-alive-enabled: func
Enables or disables keepalive.
The keepalive behavior can be adjusted using:
@@ -1517,23 +1517,23 @@ These properties can be configured while
keep-alive-enabled
is falsEquivalent to the SO_KEEPALIVE socket option.
Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+bool
,error-code
>- result<
bool
,error-code
>+
[method]tcp-socket.set-keep-alive-enabled: func
[method]tcp-socket.set-keep-alive-enabled: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:bool
- +
self
: borrow<tcp-socket
>value
:bool
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.keep-alive-idle-time: func
[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. @@ -1545,23 +1545,23 @@ I.e. after setting a value, reading the same setting back may return a differentParams
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+duration
,error-code
>- result<
duration
,error-code
>+
[method]tcp-socket.set-keep-alive-idle-time: func
[method]tcp-socket.set-keep-alive-idle-time: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:duration
- +
self
: borrow<tcp-socket
>value
:duration
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.keep-alive-interval: func
[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. @@ -1573,23 +1573,23 @@ I.e. after setting a value, reading the same setting back may return a differentParams
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+duration
,error-code
>- result<
duration
,error-code
>+
[method]tcp-socket.set-keep-alive-interval: func
[method]tcp-socket.set-keep-alive-interval: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:duration
- +
self
: borrow<tcp-socket
>value
:duration
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.keep-alive-count: func
[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. @@ -1601,23 +1601,23 @@ I.e. after setting a value, reading the same setting back may return a differentParams
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+u32
,error-code
>- result<
u32
,error-code
>+
[method]tcp-socket.set-keep-alive-count: func
[method]tcp-socket.set-keep-alive-count: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:u32
- +
self
: borrow<tcp-socket
>value
:u32
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.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.Typical errors
@@ -1626,23 +1626,23 @@ I.e. after setting a value, reading the same setting back may return a differentParams
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+u8
,error-code
>- result<
u8
,error-code
>+
[method]tcp-socket.set-hop-limit: func
[method]tcp-socket.set-hop-limit: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:u8
- +
self
: borrow<tcp-socket
>value
:u8
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.receive-buffer-size: func
[method]tcp-socket.receive-buffer-size: func
The kernel buffer space reserved for sends/receives on this socket.
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. @@ -1654,42 +1654,42 @@ I.e. after setting a value, reading the same setting back may return a differentParams
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+u64
,error-code
>- result<
u64
,error-code
>+
[method]tcp-socket.set-receive-buffer-size: func
[method]tcp-socket.set-receive-buffer-size: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:u64
- +
self
: borrow<tcp-socket
>value
:u64
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.send-buffer-size: func
[method]tcp-socket.send-buffer-size: func
Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+u64
,error-code
>- result<
u64
,error-code
>+
[method]tcp-socket.set-send-buffer-size: func
[method]tcp-socket.set-send-buffer-size: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:u64
- +
self
: borrow<tcp-socket
>value
:u64
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.subscribe: func
[method]tcp-socket.subscribe: func
Create a
pollable
which can be used to poll for, or block on, completion of any of the asynchronous operations of this socket.When
It's planned to be removed whenfinish-bind
,finish-listen
,finish-connect
oraccept
@@ -1705,13 +1705,13 @@ for more information.future
is natively supported in Preview3.Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-+
[method]tcp-socket.shutdown: func
[method]tcp-socket.shutdown: func
Initiate a graceful shutdown.
receive
: The socket is not expecting to receive any data from @@ -1738,31 +1738,31 @@ has no effect and returnsok
.Params
-
- -
self
: borrow<tcp-socket
>- +
shutdown-type
:shutdown-type
- +
self
: borrow<tcp-socket
>shutdown-type
:shutdown-type
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>Import interface wasi:sockets/tcp-create-socket@0.2.0
+Import interface wasi:sockets/tcp-create-socket@0.2.0
Types
-+
type network
type network
-#### `type error-code` +#### `type error-code` [`error-code`](#error_code)
-#### `type ip-address-family` +#### `type ip-address-family` [`ip-address-family`](#ip_address_family)
-#### `type tcp-socket` +#### `type tcp-socket` [`tcp-socket`](#tcp_socket)
----
Functions
-+
create-tcp-socket: func
create-tcp-socket: func
Create a new TCP socket.
Similar to
@@ -1784,31 +1784,31 @@ is called, the socket is effectively an in-memory configuration object, unable tsocket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP)
in POSIX. On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise.Params
-
- +
address-family
:ip-address-family
address-family
:ip-address-family
Return values
-
- result<own<
tcp-socket
>,error-code
>Import interface wasi:sockets/ip-name-lookup@0.2.0
+Import interface wasi:sockets/ip-name-lookup@0.2.0
Types
-+
type pollable
type pollable
-#### `type network` +#### `type network` [`network`](#network)
-#### `type error-code` +#### `type error-code` [`error-code`](#error_code)
-#### `type ip-address` +#### `type ip-address` [`ip-address`](#ip_address)
-#### `resource resolve-address-stream` +#### `resource resolve-address-stream`
Functions
-+
resolve-addresses: func
resolve-addresses: func
Resolve an internet host name to a list of IP addresses.
Unicode domain names are automatically converted to ASCII using IDNA encoding. If the input is an IP address string, the address is parsed and returned @@ -1830,14 +1830,14 @@ to (asynchronously) fetch the results.
Params
Return values
-
- result<own<
resolve-address-stream
>,error-code
>+
[method]resolve-address-stream.resolve-next-address: func
[method]resolve-address-stream.resolve-next-address: func
Returns the next address from the resolver.
This function should be called multiple times. On each call, it will return the next address in connection order preference. If all @@ -1852,21 +1852,21 @@ addresses have been exhausted, this function returns
none
.Params
-
- +
self
: borrow<resolve-address-stream
>self
: borrow<resolve-address-stream
>Return values
-
-- result<option<
+ip-address
>,error-code
>- result<option<
ip-address
>,error-code
>+
[method]resolve-address-stream.subscribe: func
[method]resolve-address-stream.subscribe: func
Create a
pollable
which will resolve once the stream is ready for I/O.Note: this function is here for WASI Preview2 only. It's planned to be removed when
future
is natively supported in Preview3.Params
-
- +
self
: borrow<resolve-address-stream
>self
: borrow<resolve-address-stream
>Return values