func Listen(network, address string) (Listener, error)

network 可选参数:

"tcp",
"tcp4" (IPv4-only), 
"tcp6" (IPv6-only), 
"udp", 
"udp4" (IPv4-only),
"udp6" (IPv6-only), 
"ip",
"ip4" (IPv4-only), 
"ip6" (IPv6-only), 
"unix",
 "unixgram" 
"unixpacket"
常用
tcp     自动适配,优先IPv6
tcp4    仅使用IPv4
tcp6    仅使用IPv6

记录一笔之前忽略的问题,因为大学时候的模糊概念,一直以为自己用的ipv4
另外记录一个很奇怪的问题,之前 tcp6 用来保活的的keepalive 包一直没有,换成了tcp4就有了,一脸懵逼
参考[https://www.golangnote.com/topic/256.html]

你可能感兴趣的:(func Listen(network, address string) (Listener, error))