zmq::fd_t zmq::tcp_connecter_t::connect () { // Async connect has finished. Check whether an error occurred int err = 0; #if defined ZMQ_HAVE_HPUX int len = sizeof (err); #else socklen_t len = sizeof (err); #endif #ifdef ZMQ_HAVE_BROKEN_WINCE // CE 4.2 and older do not support SO_ERROR, regardless // of what the MSDN will tell you! int rc = getWinsockConnectionError(s, err); #else int rc = getsockopt (s, SOL_SOCKET, SO_ERROR, (char*) &err, &len); #endif // Assert if the error was caused by 0MQ bug. // Networking problems are OK. No need to assert. #ifdef ZMQ_HAVE_WINDOWS wsa_assert(rc != SOCKET_ERROR); if (err != 0) { if (err == WSAECONNREFUSED || err == WSAETIMEDOUT || err == WSAECONNABORTED || err == WSAEHOSTUNREACH || err == WSAENETUNREACH || err == WSAENETDOWN || err == WSAEINVAL) return retired_fd; wsa_assert_no (err); } #else // Following code should handle both Berkeley-derived socket // implementations and Solaris. if (rc == -1) err = errno; if (err != 0) { errno = err; errno_assert ( errno == ECONNREFUSED || errno == ECONNRESET || errno == ETIMEDOUT || errno == EHOSTUNREACH || errno == ENETUNREACH || errno == ENETDOWN || errno == EINVAL); return retired_fd; } #endif // Return the newly connected socket. fd_t result = s; s = retired_fd; return result; }
zmq::fd_t zmq::tcp_connecter_t::connect () { // Async connect has finished. Check whether an error occurred int err = 0; #ifdef ZMQ_HAVE_HPUX int len = sizeof err; #else socklen_t len = sizeof err; #endif const int rc = getsockopt (s, SOL_SOCKET, SO_ERROR, (char*) &err, &len); // Assert if the error was caused by 0MQ bug. // Networking problems are OK. No need to assert. #ifdef ZMQ_HAVE_WINDOWS zmq_assert (rc == 0); if (err != 0) { if (err != WSAECONNREFUSED && err != WSAETIMEDOUT && err != WSAECONNABORTED && err != WSAEHOSTUNREACH && err != WSAENETUNREACH && err != WSAENETDOWN && err != WSAEACCES && err != WSAEINVAL && err != WSAEADDRINUSE) { wsa_assert_no (err); } return retired_fd; } #else // Following code should handle both Berkeley-derived socket // implementations and Solaris. if (rc == -1) err = errno; if (err != 0) { errno = err; errno_assert ( errno == ECONNREFUSED || errno == ECONNRESET || errno == ETIMEDOUT || errno == EHOSTUNREACH || errno == ENETUNREACH || errno == ENETDOWN || errno == EINVAL); return retired_fd; } #endif // Return the newly connected socket. const fd_t result = s; s = retired_fd; return result; }
zmq::fd_t zmq::tcp_connecter_t::connect (bool *is_interrupted) { *is_interrupted = false; // Async connect have finished. Check whether an error occured. int err = 0; #if defined ZMQ_HAVE_HPUX int len = sizeof (err); #else socklen_t len = sizeof (err); #endif int rc = getsockopt (s, SOL_SOCKET, SO_ERROR, (char*) &err, &len); // Assert if the error was caused by 0MQ bug. // Networking problems are OK. No need to assert. #ifdef ZMQ_HAVE_WINDOWS zmq_assert (rc == 0); if (err != 0) { if (err == WSAECONNREFUSED || err == WSAETIMEDOUT || err == WSAECONNABORTED || err == WSAEHOSTUNREACH || err == WSAENETUNREACH || err == WSAENETDOWN) return retired_fd; wsa_assert_no (err); } #else // Following code should handle both Berkeley-derived socket // implementations and Solaris. if (rc == -1) err = errno; if (err != 0) { errno = err; if (errno == EINTR) { *is_interrupted = true; return s; } errno_assert (errno == ECONNREFUSED || errno == ECONNRESET || errno == ETIMEDOUT || errno == EHOSTUNREACH || errno == ENETUNREACH || errno == ENETDOWN); return retired_fd; } #endif // Return the newly connected socket. fd_t result = s; s = retired_fd; return result; }
zmq::fd_t zmq::tcp_connecter_t::connect () { // Async connect has finished. Check whether an error occurred int err = 0; #ifdef ZMQ_HAVE_HPUX int len = sizeof err; #else socklen_t len = sizeof err; #endif const int rc = getsockopt (s, SOL_SOCKET, SO_ERROR, (char*) &err, &len); // Assert if the error was caused by 0MQ bug. // Networking problems are OK. No need to assert. #ifdef ZMQ_HAVE_WINDOWS zmq_assert (rc == 0); if (err != 0) { if (err == WSAEBADF || err == WSAENOPROTOOPT || err == WSAENOTSOCK || err == WSAENOBUFS) { wsa_assert_no (err); } return retired_fd; } #else // Following code should handle both Berkeley-derived socket // implementations and Solaris. if (rc == -1) err = errno; if (err != 0) { errno = err; errno_assert ( errno != EBADF && errno != ENOPROTOOPT && errno != ENOTSOCK && errno != ENOBUFS); return retired_fd; } #endif // Return the newly connected socket. const fd_t result = s; s = retired_fd; return result; }
zmq::fd_t zmq::tcp_connecter_t::connect () { // Nonblocking connect have finished. Check whether an error occured. int err = 0; socklen_t len = sizeof err; int rc = getsockopt (s, SOL_SOCKET, SO_ERROR, (char*) &err, &len); zmq_assert (rc == 0); if (err != 0) { // Assert that the error was caused by the networking problems // rather than 0MQ bug. if (err == WSAECONNREFUSED || err == WSAETIMEDOUT || err == WSAECONNABORTED || err == WSAEHOSTUNREACH || err == WSAENETUNREACH || err == WSAENETDOWN) return retired_fd; wsa_assert_no (err); } // Return the newly connected socket. fd_t result = s; s = retired_fd; return result; }