diff --git a/src/tcp_connecter.cpp b/src/tcp_connecter.cpp index 97009e61..878ba4ff 100644 --- a/src/tcp_connecter.cpp +++ b/src/tcp_connecter.cpp @@ -209,6 +209,18 @@ int zmq::tcp_connecter_t::open () // Create the socket. s = open_socket (addr->resolved.tcp_addr->family (), SOCK_STREAM, IPPROTO_TCP); + + // IPv6 address family not supported, try automatic downgrade to IPv4. + if (s == -1 && addr->resolved.tcp_addr->family () == AF_INET6 + && errno == EAFNOSUPPORT + && options.ipv6) { + int rc = addr->resolved.tcp_addr->resolve ( + addr->address.c_str (), false, false); + if (rc != 0) + return -1; + s = open_socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); + } + #ifdef ZMQ_HAVE_WINDOWS if (s == INVALID_SOCKET) { errno = wsa_error_to_errno (WSAGetLastError ());