| Previous | Next |
| EALREADY | EDESTADDRREQ |
ENOTSOCK
The descriptor is valid only as a number
ENOTSOCK means that the argument passed to a socket API does not refer to a socket object. It is not a network reachability error and it does not identify a remote endpoint. The failure is local to descriptor ownership, lifetime, or API selection.
A common diagnostic trap is to log only the integer descriptor. After one thread closes it, the kernel may reuse the same number for an unrelated file. A delayed callback can then call send(), connect(), or shutdown() on the wrong object and obtain ENOTSOCK.
Evidence to collect
- Log descriptor creation,
dup(), handoff, close, and callback ownership with a monotonically increasing connection identifier rather than the descriptor number alone. - Record the exact syscall and descriptor value.
shutdown(), for example, explicitly distinguishes a non-socket descriptor from an unconnected socket. - Check that cancellation or teardown cannot leave a queued task holding a stale descriptor after the connection object has been destroyed.
Why reconnecting does not address it
Creating another network connection may hide the race temporarily, but it cannot repair a call that used a non-socket descriptor. The defect is in local resource ownership or in choosing a socket API for a different kind of file descriptor.
References
Looking for a different code? Search another status or error code.