| 1 |
//go:build linux |
| 2 |
|
| 3 |
package socket |
| 4 |
|
| 5 |
import "golang.org/x/sys/unix" |
| 6 |
|
| 7 |
// setReadBuffer wraps the SO_RCVBUF{,FORCE} setsockopt(2) options. |
| 8 |
func (c *Conn) setReadBuffer(bytes int) error { |
| 9 |
err := c.SetsockoptInt(unix.SOL_SOCKET, unix.SO_RCVBUFFORCE, bytes) |
| 10 |
if err != nil { |
| 11 |
err = c.SetsockoptInt(unix.SOL_SOCKET, unix.SO_RCVBUF, bytes) |
| 12 |
} |
| 13 |
return err |
| 14 |
} |
| 15 |
|
| 16 |
// setWriteBuffer wraps the SO_SNDBUF{,FORCE} setsockopt(2) options. |
| 17 |
func (c *Conn) setWriteBuffer(bytes int) error { |
| 18 |
err := c.SetsockoptInt(unix.SOL_SOCKET, unix.SO_SNDBUFFORCE, bytes) |
| 19 |
if err != nil { |
| 20 |
err = c.SetsockoptInt(unix.SOL_SOCKET, unix.SO_SNDBUF, bytes) |
| 21 |
} |
| 22 |
return err |
| 23 |
} |