golang.org/x/net@v0.25.1-0.20240516223405-c87a5b62e243/nettest/nettest_unix.go (about) 1 // Copyright 2019 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 //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 7 package nettest 8 9 import "syscall" 10 11 func supportsRawSocket() bool { 12 for _, af := range []int{syscall.AF_INET, syscall.AF_INET6} { 13 s, err := syscall.Socket(af, syscall.SOCK_RAW, 0) 14 if err != nil { 15 continue 16 } 17 syscall.Close(s) 18 return true 19 } 20 return false 21 }