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

taoshuye · · 2194 次点击
权限是个思路,我再研究研究多谢了
#6
更多评论
把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