ESHUTDOWN
Linux / POSIXERRORCommonNetworkHIGH confidence
Cannot Send After Transport Endpoint Shutdown
Production Risk
Programming error; track socket shutdown state.
What this means
ESHUTDOWN (errno 108) is returned when a send operation is attempted on a socket that has been shut down for writing.
Why it happens
- 1Calling send() after shutdown(SHUT_WR) or shutdown(SHUT_RDWR)
- 2Writing to a socket after signaling end-of-stream
How to reproduce
send() after shutdown(SHUT_WR).
trigger — this will error
trigger — this will error
shutdown(sockfd, SHUT_WR); // signal end of writes // Attempt to send more data send(sockfd, buf, len, 0); // Returns -1, errno = ESHUTDOWN
expected output
send: Cannot send after transport endpoint shutdown (ESHUTDOWN)
Fix
Do not send after shutdown
WHEN Managing half-close protocol patterns
Do not send after shutdown
// Track shutdown state bool write_shut = false; shutdown(sockfd, SHUT_WR); write_shut = true; // Guard all sends: if (!write_shut) send(sockfd, buf, len, 0);
Why this works
Once shutdown(SHUT_WR) is called, no further sends are possible on that socket.
Sources
Official documentation ↗
Linux Programmer Manual shutdown(2)
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev