| Previous | Next |
| EHOSTUNREACH | EALREADY |
EISCONN
EISCONN indicates a socket has already entered a connected state and the caller attempted an operation intended for an unconnected endpoint. It is an object-lifecycle error: the socket's peer association, not the remote host's availability, makes the requested operation inappropriate.
Native Winsock code reports WSAEISCONN through WSAGetLastError(). The portable name should not obscure the operation that failed. A second connect, a send API with a conflicting destination, and a state machine that reused a socket for a new request are different bugs even when they map to the same high-level condition.
State to verify
- Record whether the socket was explicitly connected, implicitly bound, accepted from a listener, or reused from a pool.
- Inspect the current peer and local endpoints with the appropriate socket queries before reusing the object.
- Use one lifecycle owner for connect, shutdown, close, and pool return. Multiple owners produce duplicate transitions.
- Create a new socket when the protocol requires a new peer relationship; do not force a second connection onto an established object.
References
Looking for a different code? Search another status or error code.