patch 8.2.1661: cannot connect to 127.0.0.1 for host with only IPv6 addresses
Problem: Cannot connect to 127.0.0.1 for host with only IPv6 addresses.
Solution: pass AI_V4MAPPED flag to getaddrinfo. (Filipe Brandenburger,
closes #6931)
diff --git a/src/channel.c b/src/channel.c
index e73c415..bdb59f0 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -977,8 +977,8 @@
CLEAR_FIELD(hints);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
-# ifdef AI_ADDRCONFIG
- hints.ai_flags = AI_ADDRCONFIG;
+# if defined(AI_ADDRCONFIG) && defined(AI_V4MAPPED)
+ hints.ai_flags = AI_ADDRCONFIG | AI_V4MAPPED;
# endif
// Set port number manually in order to prevent name resolution services
// from being invoked in the environment where AI_NUMERICSERV is not