From 9b242ed23263e430110102ed82fa7fb9355eafbf Mon Sep 17 00:00:00 2001 From: Dave Bakker Date: Sun, 10 Sep 2023 16:10:12 +0200 Subject: [PATCH] Add SO_ACCEPTCONN support --- Posix-compatibility.md | 2 +- example-world.md | 11 +++++++++++ wit/tcp.wit | 5 +++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Posix-compatibility.md b/Posix-compatibility.md index a2ba1c6..f4249e7 100644 --- a/Posix-compatibility.md +++ b/Posix-compatibility.md @@ -151,7 +151,7 @@ Columns: | SO_DOMAIN | ✅ | ❌ | ✅ | ✅ | ❌ | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | [`tcp::address-family`](tcp)
[`udp::address-family`](udp)

SO_PROTOCOL_INFO on Windows. | | SO_TYPE | ✅* | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | * indirectly through the type of the socket resource. | | SO_PROTOCOL | ✅* | ❌ | ✅ | ✅ | ❌ | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | * indirectly through the type of the socket resource. SO_PROTOCOL_INFO on Windows. | -| SO_ACCEPTCONN | ❔ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | | +| SO_ACCEPTCONN | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | [`tcp::is-listening`](tcp) | | IPV6_V6ONLY | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | [`tcp::(set-)ipv6-only`](tcp)
[`udp::(set-)ipv6-only`](udp) | | IP_HDRINCL | ⛔ | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | Out of scope. Raw sockets only. | | IPV6_HDRINCL | ⛔ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | Out of scope. Raw sockets only. | diff --git a/example-world.md b/example-world.md index 8c74520..cb39897 100644 --- a/example-world.md +++ b/example-world.md @@ -1228,6 +1228,17 @@ a pair of streams that can be used to read & write to the connection.

+

is-listening: func

+

Whether the socket is listening for new connections.

+

Equivalent to the SO_ACCEPTCONN socket option.

+
Params
+ +
Return values
+

address-family: func

Whether this is a IPv4 or IPv6 socket.

Equivalent to the SO_DOMAIN socket option.

diff --git a/wit/tcp.wit b/wit/tcp.wit index 4edb1db..0e3f27e 100644 --- a/wit/tcp.wit +++ b/wit/tcp.wit @@ -154,6 +154,11 @@ interface tcp { /// - remote-address: func(this: tcp-socket) -> result + /// Whether the socket is listening for new connections. + /// + /// Equivalent to the SO_ACCEPTCONN socket option. + is-listening: func(this: tcp-socket) -> bool + /// Whether this is a IPv4 or IPv6 socket. /// /// Equivalent to the SO_DOMAIN socket option.