net: enable SO_REUSEADDR, SO_REUSEPORT options on stream, multicast listeners only

This CL changes default SOL_SOCKET settings to mitigate connect
failure on OpenBSD or similar platforms which support randomized
transport protocol port number assignment.

Fixes #2830.

R=rsc, jsing
CC=golang-dev
https://golang.org/cl/5648044
diff --git a/src/pkg/net/sockopt_windows.go b/src/pkg/net/sockopt_windows.go
index 842bccc..46661e2 100644
--- a/src/pkg/net/sockopt_windows.go
+++ b/src/pkg/net/sockopt_windows.go
@@ -18,16 +18,18 @@
 		// Note that some operating systems never admit this option.
 		syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, 0)
 	}
+	// Allow broadcast.
+	syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1)
+	return nil
+}
 
+func setDefaultListenerSockopts(s syscall.Handle, f, t int) error {
 	// 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)
 	return nil
 }