golang编写ping失败,求大神指点

taoshuye · · 2172 次点击
谢啦,还真是的
#11
更多评论
把conn, err := net.DialIP("ip4:icmp", &laddr, &raddr) 换成 conn, err := net.Dial("ip4:icmp", address) 试试
#1
换掉以后,并注解掉//laddr net.IPAddr = net.IPAddr{IP: net.ParseIP("192.168.31.11")} // raddr net.IPAddr = net.IPAddr{IP: net.ParseIP("192.168.31.1")}两行,仍显示: socket: An attempt was made to access a socket in a way forbidden by its access permissions.
#2