fix(stream): use platform-specific socket options for Windows cross-compilation

This commit is contained in:
Deivid Soto 2026-04-07 19:18:13 +02:00
parent 55fb74c814
commit 264be4e309
3 changed files with 19 additions and 1 deletions

View file

@ -0,0 +1,9 @@
//go:build !windows
package engine
import "syscall"
func setReuseAddr(fd uintptr) error {
return syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
}

View file

@ -0,0 +1,9 @@
//go:build windows
package engine
import "syscall"
func setReuseAddr(fd uintptr) error {
return syscall.SetsockoptInt(syscall.Handle(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
}

View file

@ -72,7 +72,7 @@ func (ss *StreamServer) Listen(ctx context.Context) error {
lc := net.ListenConfig{
Control: func(network, address string, c syscall.RawConn) error {
return c.Control(func(fd uintptr) {
_ = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
_ = setReuseAddr(fd)
})
},
}