github.com/igoogolx/clash@v1.19.8/common/sockopt/reuseaddr_linux.go (about) 1 package sockopt 2 3 import ( 4 "net" 5 "syscall" 6 ) 7 8 func UDPReuseaddr(c *net.UDPConn) (err error) { 9 rc, err := c.SyscallConn() 10 if err != nil { 11 return 12 } 13 14 rc.Control(func(fd uintptr) { 15 err = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1) 16 }) 17 18 return 19 }