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

taoshuye · · 2179 次点击
因为明显英文的提示就是说:禁止创建一个socket,我知道在linux下加sudo权限就好了,至于windows,我不用,所以也不懂,帮不到你,不好意思
#7
更多评论
把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