diff --git a/src/tcp_connecter.cpp b/src/tcp_connecter.cpp index f74931a8..504268a1 100644 --- a/src/tcp_connecter.cpp +++ b/src/tcp_connecter.cpp @@ -218,20 +218,17 @@ int zmq::tcp_connecter_t::open () if (rc == 0) return 0; - // Translate other error codes indicating asynchronous connect has been + // Translate error codes indicating asynchronous connect has been // launched to a uniform EINPROGRESS. #ifdef ZMQ_HAVE_WINDOWS - if (rc == SOCKET_ERROR && (WSAGetLastError () == WSAEINPROGRESS || - WSAGetLastError () == WSAEWOULDBLOCK)) { + const int error_code = WSAGetLastError (); + if (error_code == WSAEINPROGRESS || error_code == WSAEWOULDBLOCK) errno = EINPROGRESS; - return -1; - } - errno = wsa_error_to_errno (WSAGetLastError ()); + else + errno = wsa_error_to_errno (error_code); #else - if (rc == -1 && errno == EINTR) { + if (errno == EINTR) errno = EINPROGRESS; - return -1; - } #endif return -1; }