...

Source file src/github.com/mdlayher/socket/setbuffer_linux.go

Documentation: github.com/mdlayher/socket

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

View as plain text