From b6c6b96c79a5c64d98fd77162c4427811e69c2e1 Mon Sep 17 00:00:00 2001 From: Ryan Huber Date: Wed, 17 Mar 2021 18:21:42 -0500 Subject: [PATCH] also darwin --- udp_darwin.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/udp_darwin.go b/udp_darwin.go index 4f7c0b2..4f43658 100644 --- a/udp_darwin.go +++ b/udp_darwin.go @@ -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) {