1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // Socket options for Windows
13 func setDefaultSockopts(s syscall.Handle, f, p int) {
15 case syscall.AF_INET6:
16 // Allow both IP versions even if the OS default is otherwise.
17 syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, 0)
20 // Windows will reuse recently-used addresses by default.
21 // SO_REUSEADDR should not be used here, as it allows
22 // a socket to forcibly bind to a port in use by another socket.
23 // This could lead to a non-deterministic behavior, where
24 // connection requests over the port cannot be guaranteed
25 // to be handled by the correct socket.
28 syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1)
32 func setDefaultMulticastSockopts(fd *netFD) {
35 // Allow multicast UDP and raw IP datagram sockets to listen
36 // concurrently across multiple listeners.
37 syscall.SetsockoptInt(fd.sysfd, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)