Skip to content

Commit c3733b2

Browse files
committed
net: document why we do not use SO_REUSEADDR on windows
R=rsc, adg CC=golang-dev https://golang.org/cl/5302058
1 parent 704bf77 commit c3733b2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/pkg/net/sock_windows.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ import (
1111
)
1212

1313
func setKernelSpecificSockopt(s syscall.Handle, f int) {
14+
// Windows will reuse recently-used addresses by default.
15+
// SO_REUSEADDR should not be used here, as it allows
16+
// a socket to forcibly bind to a port in use by another socket.
17+
// This could lead to a non-deterministic behavior, where
18+
// connection requests over the port cannot be guaranteed
19+
// to be handled by the correct socket.
20+
1421
// Allow broadcast.
1522
syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1)
1623

0 commit comments

Comments
 (0)