| Previous | Next |
| ENOLCK | ECHRNG |
EALREADY
The socket already has an unfinished request
EALREADY is a concurrency and state-management result. It commonly appears when code calls connect() again after a nonblocking connection attempt has already returned EINPROGRESS. The second call does not create a second independent connection attempt.
The useful question is not whether the destination is reachable in general, but which part of the program still owns this socket's pending operation. A retry timer, cancellation path, and event-loop callback must not all issue a new connect() against the same descriptor.
How to resolve the state safely
- Associate one explicit connection-state record with the file descriptor and let only that owner consume readiness and timeout events.
- After readiness, query
SO_ERRORonce and transition to connected, failed, or closed; do not infer success from an event notification alone. - If the deadline expires, close or otherwise retire the pending socket before starting a fresh attempt. Reusing an ambiguous descriptor makes later errors hard to attribute.
Nearby errors have different meanings
EINPROGRESS describes the first pending result. EISCONN reports a completed connected state. ECONNREFUSED, ETIMEDOUT, and EHOSTUNREACH are final outcomes that may be discovered only after the pending attempt completes.
References
Looking for a different code? Search another status or error code.