No Buffer Space Available
Production Risk
Common in high-throughput UDP applications; implement backpressure or increase buffers.
ENOBUFS (errno 105) is returned when the kernel cannot allocate a buffer for a network operation, typically because the socket send/receive buffer is exhausted or the system is out of memory for socket buffers.
- 1Socket send buffer is full and the socket is non-blocking
- 2Kernel socket buffer memory exhausted (rmem_max/wmem_max exceeded)
- 3Very high packet rate consuming all socket buffer space
Non-blocking send when socket buffer is full.
// Non-blocking UDP send when buffers are exhausted int n = send(sockfd, buf, len, MSG_DONTWAIT); // Returns -1, errno = ENOBUFS
expected output
send: No buffer space available (ENOBUFS)
Fix 1
Increase socket buffer sizes
WHEN When ENOBUFS occurs under sustained high throughput
// Increase socket send buffer int bufsize = 4 * 1024 * 1024; // 4MB setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize)); # Or increase system-wide limits: sysctl -w net.core.wmem_max=8388608 sysctl -w net.core.rmem_max=8388608
Why this works
Larger socket buffers allow the kernel to queue more data during bursts.
Fix 2
Implement backpressure on ENOBUFS
WHEN In high-throughput non-blocking applications
int n = send(sockfd, buf, len, MSG_DONTWAIT);
if (n == -1 && errno == ENOBUFS) {
// Back off — wait for buffer to drain
struct pollfd pfd = { .fd = sockfd, .events = POLLOUT };
poll(&pfd, 1, 100); // wait up to 100ms
}Why this works
poll() with POLLOUT blocks until the send buffer has space.
Linux Programmer Manual socket(7)
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev