From f6e12a1f4ec964a8fdb4efd7a0e7c8dfadbf9057 Mon Sep 17 00:00:00 2001
From: Dave Bakker
Date: Wed, 3 Jan 2024 10:49:05 +0100
Subject: [PATCH 1/2] Make SO_REUSEADDR the default for TCP sockets
---
imports.md | 4 ++++
wit/tcp.wit | 5 +++++
2 files changed, 9 insertions(+)
diff --git a/imports.md b/imports.md
index 497f48d..f0fa5c3 100644
--- a/imports.md
+++ b/imports.md
@@ -1190,6 +1190,10 @@ implicitly bind the socket.
not-in-progress
: A bind
operation is not in progress.
would-block
: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN)
+Implementors note
+When binding to a non-zero port, this bind operation shouldn't be affected by the TIME_WAIT
+state of a recently closed socket on the same local address (i.e. the SO_REUSEADDR socket
+option should be set implicitly on platforms that require it).
References
- https://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html
diff --git a/wit/tcp.wit b/wit/tcp.wit
index b01b65e..976b272 100644
--- a/wit/tcp.wit
+++ b/wit/tcp.wit
@@ -42,6 +42,11 @@ interface tcp {
/// - `address-not-bindable`: `local-address` is not an address that the `network` can bind to. (EADDRNOTAVAIL)
/// - `not-in-progress`: A `bind` operation is not in progress.
/// - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN)
+ ///
+ /// # Implementors note
+ /// When binding to a non-zero port, this bind operation shouldn't be affected by the TIME_WAIT
+ /// state of a recently closed socket on the same local address (i.e. the SO_REUSEADDR socket
+ /// option should be set implicitly on platforms that require it).
///
/// # References
/// -
From 6907592886b1c76e9447db571b90af8f3fa515a8 Mon Sep 17 00:00:00 2001
From: Dave Bakker
Date: Wed, 3 Jan 2024 16:45:18 +0100
Subject: [PATCH 2/2] Add note about the Windows behavior
---
imports.md | 5 +++--
wit/tcp.wit | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/imports.md b/imports.md
index f0fa5c3..cdbe6e6 100644
--- a/imports.md
+++ b/imports.md
@@ -1192,8 +1192,9 @@ implicitly bind the socket.
Implementors note
When binding to a non-zero port, this bind operation shouldn't be affected by the TIME_WAIT
-state of a recently closed socket on the same local address (i.e. the SO_REUSEADDR socket
-option should be set implicitly on platforms that require it).
+state of a recently closed socket on the same local address. In practice this means that the SO_REUSEADDR
+socket option should be set implicitly on all platforms, except on Windows where this is the default behavior
+and SO_REUSEADDR performs something different entirely.
References
- https://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html
diff --git a/wit/tcp.wit b/wit/tcp.wit
index 976b272..337d606 100644
--- a/wit/tcp.wit
+++ b/wit/tcp.wit
@@ -45,8 +45,9 @@ interface tcp {
///
/// # Implementors note
/// When binding to a non-zero port, this bind operation shouldn't be affected by the TIME_WAIT
- /// state of a recently closed socket on the same local address (i.e. the SO_REUSEADDR socket
- /// option should be set implicitly on platforms that require it).
+ /// state of a recently closed socket on the same local address. In practice this means that the SO_REUSEADDR
+ /// socket option should be set implicitly on all platforms, except on Windows where this is the default behavior
+ /// and SO_REUSEADDR performs something different entirely.
///
/// # References
/// -