From df2e6d3de2eba9187c3e791429687e8e02b6b551 Mon Sep 17 00:00:00 2001 From: Dave Bakker Date: Sat, 11 Nov 2023 09:46:39 +0100 Subject: [PATCH] Add & refine socket options. (SO_ACCEPTCONN, TCP_KEEPIDLE/INTVL/CNT) - Add support for the socket options: - `is-listening` (`SO_ACCEPTCONN`) - `keep-alive-count` (`TCP_KEEPCNT`) - `keep-alive-idle-time` (`TCP_KEEPIDLE`) - `keep-alive-interval` (`TCP_KEEPINTVL`) - Tweak existing socket options: - Rename `keep-alive` to `keep-alive-enabled`, since it is no longer the only "keep-alive"-related option. - Rename `(set-)unicast-hop-limit` to `(set-)hop-limit`, because the "unicast" qualifier is redundant for TCP. - Be stricter in that `0` is not a valid value for: - `set-listen-backlog-size` - `set-hop-limit` - `set-receive-buffer-size` - `set-send-buffer-size` --- imports.md | 315 ++++++++++++++++++++++------ wit/deps.lock | 5 + wit/deps.toml | 1 + wit/deps/clocks/monotonic-clock.wit | 45 ++++ wit/deps/clocks/wall-clock.wit | 42 ++++ wit/deps/clocks/world.wit | 6 + wit/tcp.wit | 84 ++++++-- wit/udp.wit | 17 +- 8 files changed, 435 insertions(+), 80 deletions(-) create mode 100644 wit/deps/clocks/monotonic-clock.wit create mode 100644 wit/deps/clocks/wall-clock.wit create mode 100644 wit/deps/clocks/world.wit diff --git a/imports.md b/imports.md index c59a6a2..497f48d 100644 --- a/imports.md +++ b/imports.md @@ -2,19 +2,21 @@ -

Import interface wasi:sockets/network

+

Import interface wasi:sockets/network@0.2.0-rc-2023-11-10


Types

resource network

@@ -184,7 +186,7 @@ combined with a couple of errors that are always possible:

  • ipv4: ipv4-socket-address
  • ipv6: ipv6-socket-address
  • -

    Import interface wasi:sockets/instance-network

    +

    Import interface wasi:sockets/instance-network@0.2.0-rc-2023-11-10

    This interface provides a value-export of the default network handle..


    Types

    @@ -199,7 +201,7 @@ combined with a couple of errors that are always possible:

    -

    Import interface wasi:io/poll

    +

    Import interface wasi:io/poll@0.2.0-rc-2023-11-10

    A poll API intended to let users wait for I/O events on multiple handles at once.


    @@ -249,7 +251,7 @@ being reaedy for I/O.

    -

    Import interface wasi:sockets/udp

    +

    Import interface wasi:sockets/udp@0.2.0-rc-2023-11-10


    Types

    type pollable

    @@ -489,6 +491,11 @@ stored in the object pointed to by 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.

    +

    Typical errors

    +
    Params

    [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.

    +

    Typical errors

    +
    Params