WebAssembly / wasi-sockets

WASI API proposal for managing sockets
243 stars 22 forks source link

Sync changes from wasmtime repo #70

Closed badeend closed 11 months ago

badeend commented 11 months ago

TCP

WASI is stricter and requires local-address to return invalid-state when the socket hasn't been bound yet.


- Remove TCP_NODELAY for the time being. The semantics of TCP_NODELAY (and TCP_CORK for that matter) and its effects on the output-stream needs to investigated and specified. I don't expect there to be anything insurmountable. Its just that I haven't had the time to do so yet and I can't promise to have it done before the stabilization Preview2. So, in order to get wasi-sockets ready for Preview2, it was discussed to temporarily remove `no-delay` and reevaluate its inclusion before Preview3.
- 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`)
- 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.
- Clarify what implementations must and must not accept as valid inputs for:
    - `set-listen-backlog-size`
    - `set-hop-limit`
    - `set-receive-buffer-size`
    - `set-send-buffer-size`

# UDP

- Introduce new `incoming-datagram-stream` and `outgoing-datagram-stream` types and moved `receive` and `send` methods to those respectively. These streams are returned by `stream` and can be individually subscribed to. This resolves a design issue where a UDP server would end up in a spin loop because `receive` returned EWOULDBLOCK but poll_* always returned immediately because the socket was ready for sending. In this new setup, users can poll each direction separately. Fixes https://github.com/WebAssembly/wasi-sockets/issues/64
- Dropped the `network` parameter from the `connect` call, because `bind` is now _required_ to perform IO.
- Enable send-like behaviour by making `outgoing-datagram::remote-address` optional. Fixes https://github.com/WebAssembly/wasi-sockets/pull/57
- Clarify what implementations must and must not accept as valid inputs for:
    - `set-unicast-hop-limit`
    - `set-receive-buffer-size`
    - `set-send-buffer-size`

# IP name lookup
- Remove the non-essential parameters for now. Post-preview2 these can be reevaluated again.
- Lift the restriction against parsing IP addresses. Before, implementations still needed to parse IP addresses to decide whether or not to return an error.
pchickey commented 11 months ago

I missed that this PR hadn't landed yet before tagging the RC in #71, so I reverted that PR in #72. Can we merge this as soon as possible, and I'll continue with the release candidate tagging then?