mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-15 05:31:18 +08:00
20 lines
283 B
Go
20 lines
283 B
Go
|
package sockopt
|
||
|
|
||
|
import (
|
||
|
"net"
|
||
|
"syscall"
|
||
|
)
|
||
|
|
||
|
func UDPReuseaddr(c *net.UDPConn) (err error) {
|
||
|
rc, err := c.SyscallConn()
|
||
|
if err != nil {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
rc.Control(func(fd uintptr) {
|
||
|
err = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
|
||
|
})
|
||
|
|
||
|
return
|
||
|
}
|