]> Cypherpunks repositories - gostls13.git/commitdiff
net: document why we do not use SO_REUSEADDR on windows
authorAlex Brainman <alex.brainman@gmail.com>
Wed, 26 Oct 2011 11:25:20 +0000 (22:25 +1100)
committerAlex Brainman <alex.brainman@gmail.com>
Wed, 26 Oct 2011 11:25:20 +0000 (22:25 +1100)
R=rsc, adg
CC=golang-dev
https://golang.org/cl/5302058

src/pkg/net/sock_windows.go

index 5169d1e6a29ea58ccaa365aa403a2b31da9ec6a3..9b9cd9e368bf5dc3dd3d897d1433c81e082ee949 100644 (file)
@@ -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)