Operation Now in Progress
Production Risk
Expected behavior for non-blocking connect; not a real error — always handle with poll/select.
EINPROGRESS (errno 115) is returned by connect() on a non-blocking socket to indicate that the connection cannot be completed immediately — it is in progress and will complete asynchronously.
- 1connect() on a non-blocking socket — this is normal behavior, not an error
Non-blocking connect() initiation.
fcntl(sockfd, F_SETFL, O_NONBLOCK); int rc = connect(sockfd, (struct sockaddr*)&addr, sizeof(addr)); // Returns -1, errno = EINPROGRESS — NOT a real error, just async
expected output
connect: Operation now in progress (EINPROGRESS)
Fix
Wait for POLLOUT then check SO_ERROR
WHEN After non-blocking connect() returns EINPROGRESS
// EINPROGRESS means connect is in progress — use poll
struct pollfd pfd = { .fd = sockfd, .events = POLLOUT };
int rc = poll(&pfd, 1, 5000); // 5 second timeout
int err = 0; socklen_t errlen = sizeof(err);
getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &err, &errlen);
if (err == 0) {
// Connected successfully
} else {
// Connection failed — err contains the actual errno
close(sockfd);
}Why this works
POLLOUT fires when connect completes. SO_ERROR = 0 means success; non-zero is the connection failure reason.
✕ Treat EINPROGRESS as a fatal error
EINPROGRESS is the expected return from non-blocking connect(); it means the handshake is underway.
Linux Programmer Manual connect(2)
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev