| Previous | Next |
| EISCONN | ESHUTDOWN |
ENOTCONN
The operation requires peer state that the socket does not have
ENOTCONN occurs when an API requires a connected peer but the socket is not connected. It can follow an attempt to send or receive on a connection-mode socket before connection setup completed, after teardown, or on a datagram-style socket that has no default peer.
The error is local state, not remote refusal. For a connectionless send, the correct API may be one that supplies a destination with the message; for a connection-mode socket, the program must complete and verify connection establishment first.
What to retain
- Log the socket type, current connection state, last connect result, and whether the call was
send(),sendto(),recv(), orshutdown(). - Check for a race between connection completion and a worker that starts I/O, especially after a nonblocking
EINPROGRESSresult. - After a failure or close, retire the old socket state rather than allowing queued application work to continue as though it still had a peer.
Contrast with address omission
EDESTADDRREQ is the connectionless case where a send needs an explicit destination. ENOTCONN is the connected-operation case where the API needs a peer association that has not been established.
References
Looking for a different code? Search another status or error code.