net: document why we do not use SO_REUSEADDR on windows
R=rsc, adg
CC=golang-dev
https://golang.org/cl/5302058
diff --git a/src/pkg/net/sock_windows.go b/src/pkg/net/sock_windows.go
index 5169d1e..9b9cd9e 100644
--- a/src/pkg/net/sock_windows.go
+++ b/src/pkg/net/sock_windows.go
@@ -11,6 +11,13 @@
)
func setKernelSpecificSockopt(s syscall.Handle, f int) {
+ // Windows will reuse recently-used addresses by default.
+ // SO_REUSEADDR should not be used here, as it allows
+ // a socket to forcibly bind to a port in use by another socket.
+ // This could lead to a non-deterministic behavior, where
+ // connection requests over the port cannot be guaranteed
+ // to be handled by the correct socket.
+
// Allow broadcast.
syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1)