Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version
)?
go version go1.7 linux/amd64
What operating system and processor architecture are you using (go env
)?
GOARCH="amd64"
GOOS="linux"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build351337243=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
What did you do?
import (
"golang.org/x/net/ipv4"
"net"
)
func main() {
c, err := net.ListenPacket("ip4", "0.0.0.0")
if err != nil {
println(err.Error())
return
}
defer c.Close()
p, err := ipv4.NewRawConn(c)
if err != nil {
println(err.Error())
return
}
_ = p
}
What did you expect to see?
It shows: listen ip4 0.0.0.0: socket: protocol not supported
but it works @ Darwin properly
https://golang.org/pkg/net/#ListenPacket
func ListenPacket(net, laddr string) (PacketConn, error)
ListenPacket announces on the local network address laddr. The network net must be a packet-oriented network: "udp", "udp4", "udp6", "ip", "ip4", "ip6" or "unixgram". For TCP and UDP, the syntax of laddr is "host:port", like "127.0.0.1:8080". If host is omitted, as in ":8080", ListenPacket listens on all available interfaces instead of just the interface with the given host address. See Dial for the syntax of laddr.
What did you see instead?
listen ip4 0.0.0.0: socket: protocol not supported