2021-09-06 23:07:34 +08:00
|
|
|
package dialer
|
|
|
|
|
|
|
|
import (
|
2023-02-13 11:14:19 +08:00
|
|
|
"context"
|
2021-09-06 23:07:34 +08:00
|
|
|
"net"
|
|
|
|
"syscall"
|
|
|
|
|
|
|
|
"golang.org/x/sys/windows"
|
|
|
|
)
|
|
|
|
|
|
|
|
func addrReuseToListenConfig(lc *net.ListenConfig) {
|
2023-02-13 11:14:19 +08:00
|
|
|
addControlToListenConfig(lc, func(ctx context.Context, network, address string, c syscall.RawConn) error {
|
2021-09-06 23:07:34 +08:00
|
|
|
return c.Control(func(fd uintptr) {
|
|
|
|
windows.SetsockoptInt(windows.Handle(fd), windows.SOL_SOCKET, windows.SO_REUSEADDR, 1)
|
|
|
|
})
|
2023-02-13 11:14:19 +08:00
|
|
|
})
|
2021-09-06 23:07:34 +08:00
|
|
|
}
|