aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2018-02-09 11:34:16 +0200
committerArnold D. Robbins <arnold@skeeve.com>2018-02-09 11:34:16 +0200
commit96685ed2909ec198bf28ba81ccff755ea88ecda7 (patch)
tree105d924a67f774a38225d4435ba11130c420f508 /io.c
parent7c32c835b7f15d2906a691fa7776d3fcd77be0f7 (diff)
parenta7512f3eb03ae2b6361e56518a2f405e386315a0 (diff)
downloadegawk-96685ed2909ec198bf28ba81ccff755ea88ecda7.tar.gz
egawk-96685ed2909ec198bf28ba81ccff755ea88ecda7.tar.bz2
egawk-96685ed2909ec198bf28ba81ccff755ea88ecda7.zip
Merge branch 'master' into feature/fix-comments
Diffstat (limited to 'io.c')
-rw-r--r--io.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/io.c b/io.c
index befc20a1..f09c4a02 100644
--- a/io.c
+++ b/io.c
@@ -1579,10 +1579,23 @@ socketopen(int family, int type, const char *localpname,
int any_remote_host = (strcmp(remotehostname, "0") == 0);
memset(& lhints, '\0', sizeof (lhints));
- lhints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
+
lhints.ai_socktype = type;
lhints.ai_family = family;
+ /*
+ * If only the loopback interface is up and hints.ai_flags has
+ * AI_ADDRCONFIG, getaddrinfo() will succeed and return all wildcard
+ * addresses, but only if hints.ai_family == AF_UNSPEC
+ *
+ * Do return the wildcard address in case the loopback interface
+ * is the only one that is up (and
+ * hints.ai_family == either AF_INET4 or AF_INET6)
+ */
+ lhints.ai_flags = AI_PASSIVE;
+ if (lhints.ai_family == AF_UNSPEC)
+ lhints.ai_flags |= AI_ADDRCONFIG;
+
lerror = getaddrinfo(NULL, localpname, & lhints, & lres);
if (lerror) {
if (strcmp(localpname, "0") != 0) {