From: Alex Brainman Date: Wed, 26 Oct 2011 11:25:20 +0000 (+1100) Subject: net: document why we do not use SO_REUSEADDR on windows X-Git-Tag: weekly.2011-11-01~61 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c3733b29d494995859bb6d6241797f67ece4c53d;p=gostls13.git 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 5169d1e6a2..9b9cd9e368 100644 --- a/src/pkg/net/sock_windows.go +++ b/src/pkg/net/sock_windows.go @@ -11,6 +11,13 @@ import ( ) 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)