also darwin

This commit is contained in:
Ryan Huber 2021-03-17 18:21:42 -05:00
parent 6dea7760cb
commit b6c6b96c79
1 changed files with 26 additions and 0 deletions

View File

@ -13,6 +13,32 @@ import (
func NewListenConfig(multi bool) net.ListenConfig {
return net.ListenConfig{
Control: func(network, address string, c syscall.RawConn) error {
var controlErr error
err := c.Control(func(fd uintptr) {
if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_SNDBUF, 999999); err != nil {
controlErr = fmt.Errorf("SO_SNDBUF failed: %v", err)
return
}
})
if err != nil {
return err
}
if controlErr != nil {
return controlErr
}
err = c.Control(func(fd uintptr) {
if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_RCVBUF, 999999); err != nil {
controlErr = fmt.Errorf("SO_RCVBUF failed: %v", err)
return
}
})
if err != nil {
return err
}
if controlErr != nil {
return controlErr
}
if multi {
var controlErr error
err := c.Control(func(fd uintptr) {