github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/internal/syscall/windows/version_windows.go (about) 1 // Copyright 2024 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. 4 5 package windows 6 7 import ( 8 "github.com/shogo82148/std/sync" 9 "github.com/shogo82148/std/syscall" 10 "github.com/shogo82148/std/unsafe" 11 ) 12 13 // SupportTCPKeepAliveInterval indicates whether TCP_KEEPIDLE is supported. 14 // The minimal requirement is Windows 10.0.16299. 15 func SupportTCPKeepAliveIdle() bool 16 17 // SupportTCPKeepAliveInterval indicates whether TCP_KEEPINTVL is supported. 18 // The minimal requirement is Windows 10.0.16299. 19 func SupportTCPKeepAliveInterval() bool 20 21 // SupportTCPKeepAliveCount indicates whether TCP_KEEPCNT is supported. 22 // supports TCP_KEEPCNT. 23 // The minimal requirement is Windows 10.0.15063. 24 func SupportTCPKeepAliveCount() bool 25 26 // SupportTCPInitialRTONoSYNRetransmissions indicates whether the current 27 // Windows version supports the TCP_INITIAL_RTO_NO_SYN_RETRANSMISSIONS. 28 // The minimal requirement is Windows 10.0.16299. 29 var SupportTCPInitialRTONoSYNRetransmissions = sync.OnceValue(func() bool { 30 major, _, build := version() 31 return major >= 10 && build >= 16299 32 }) 33 34 // SupportUnixSocket indicates whether the current Windows version supports 35 // Unix Domain Sockets. 36 // The minimal requirement is Windows 10.0.17063. 37 var SupportUnixSocket = sync.OnceValue(func() bool { 38 var size uint32 39 40 _, _ = syscall.WSAEnumProtocols(nil, nil, &size) 41 n := int32(size) / int32(unsafe.Sizeof(syscall.WSAProtocolInfo{})) 42 43 buf := make([]syscall.WSAProtocolInfo, n) 44 n, err := syscall.WSAEnumProtocols(nil, &buf[0], &size) 45 if err != nil { 46 return false 47 } 48 for i := int32(0); i < n; i++ { 49 if buf[i].AddressFamily == syscall.AF_UNIX { 50 return true 51 } 52 } 53 return false 54 })