| Previous | Next |
| EHOSTUNREACH | EINPROGRESS |
EALREADY
EALREADY is a socket state result. It commonly appears when code calls connect() again before an earlier nonblocking connection attempt has completed. The second call does not create a second connection and does not tell you whether the original attempt will succeed.
The normal sequence is to call connect(), receive EINPROGRESS, wait for the socket to become writable with poll(), select(), or an equivalent event mechanism, and then query SO_ERROR with getsockopt(). A writable event alone is not proof of success: SO_ERROR carries the final connection result.
Some Linux send paths can also use EALREADY for a TCP Fast Open attempt already in progress. Therefore logs should record the API call, socket type, and any flags instead of treating the name as a generic network failure.
Common implementation mistakes
- Starting another
connect()from every writable notification. - Forgetting to clear the “connecting” state after reading
SO_ERROR. - Reusing a socket after a failed completion instead of closing it and starting with a new socket.
POSIX connect() · Linux connect(2) · Linux send(2) and TCP Fast Open
Looking for a different code? Search another status or error code.