github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/net/internal/nettest/stack.go (about) 1 // Copyright 2014 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 nettest provides utilities for IP testing. 6 package nettest // import "golang.org/x/net/internal/nettest" 7 8 import "net" 9 10 // SupportsIPv4 reports whether the platform supports IPv4 networking 11 // functionality. 12 func SupportsIPv4() bool { 13 ln, err := net.Listen("tcp4", "127.0.0.1:0") 14 if err != nil { 15 return false 16 } 17 ln.Close() 18 return true 19 } 20 21 // SupportsIPv6 reports whether the platform supports IPv6 networking 22 // functionality. 23 func SupportsIPv6() bool { 24 ln, err := net.Listen("tcp6", "[::1]:0") 25 if err != nil { 26 return false 27 } 28 ln.Close() 29 return true 30 } 31 32 // ProtocolNotSupported reports whether err is a protocol not 33 // supported error. 34 func ProtocolNotSupported(err error) bool { 35 return protocolNotSupported(err) 36 }