sockbuf

package
v0.6.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 0 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sockbuf reports and sets socket buffer sizes on Darwin, making the kernel's silent clamping visible to the caller.

macOS clamps SO_SNDBUF and SO_RCVBUF requests to the kern.ipc.maxsockbuf sysctl ceiling without returning an error: a request for 8 MiB may install 2 MiB and report success. Code that sizes buffers with setsockopt alone cannot tell that it was truncated.

The functions here read the value back after setting it and return what the kernel actually installed. A returned size smaller than the requested size is not an error; it is the kernel's answer, and comparing the two is the only reliable way to detect the clamp.

Entry points accept a raw file descriptor ([SetRecvBuffer], [SetSendBuffer]), a syscall.RawConn ([SetRecvBufferRawConn], [SetSendBufferRawConn]), or any syscall.Conn such as *net.UDPConn and *net.TCPConn ([SetRecvBufferConn], [SetSendBufferConn]).

Performance note: existing throughput measurements pairing this package with x/udpbatch are loopback-only. Loopback buffer-sizing gains reflect local kernel queue headroom rather than wire pacing, NIC rings, or network loss; validate buffer sizing on the target interface and peer.

This package uses only public APIs and works on any Darwin version.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL