diff options
Diffstat (limited to 'libgo/go/net/sockopt_windows.go')
-rw-r--r-- | libgo/go/net/sockopt_windows.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/libgo/go/net/sockopt_windows.go b/libgo/go/net/sockopt_windows.go index b18af67d754..509b5963bf3 100644 --- a/libgo/go/net/sockopt_windows.go +++ b/libgo/go/net/sockopt_windows.go @@ -11,12 +11,17 @@ import ( "syscall" ) -func setDefaultSockopts(s syscall.Handle, f, t int) error { +func setDefaultSockopts(s syscall.Handle, f, t int, ipv6only bool) error { switch f { case syscall.AF_INET6: - // Allow both IP versions even if the OS default is otherwise. - // Note that some operating systems never admit this option. - syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, 0) + if ipv6only { + syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, 1) + } else { + // Allow both IP versions even if the OS default + // is otherwise. 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) |