#ifdef AI_ADDRCONFIG since older IPv4-only systems may not define this flag,
[mmh] / sbr / client.c
index ae6968f..d3374ad 100644 (file)
@@ -60,7 +60,9 @@ client (char *args, char *service, char *response, int len_response, int debug)
     }
 
     memset(&hints, 0, sizeof(hints));
+#ifdef AI_ADDRCONFIG
     hints.ai_flags = AI_ADDRCONFIG;
+#endif
     hints.ai_family = PF_UNSPEC;
     hints.ai_socktype = SOCK_STREAM;
 
@@ -85,7 +87,7 @@ client (char *args, char *service, char *response, int len_response, int debug)
                char address[NI_MAXHOST];
 
                rc = getnameinfo(ai->ai_addr, ai->ai_addrlen, address,
-                                sizeof(address), NULL, NULL, NI_NUMERICHOST);
+                                sizeof(address), NULL, 0, NI_NUMERICHOST);
 
                fprintf(stderr, "Connecting to %s...\n",
                        rc ? "unknown" : address);
@@ -111,9 +113,10 @@ client (char *args, char *service, char *response, int len_response, int debug)
 
            close(sd);
        }
+
+       freeaddrinfo(res);
     }
 
-    freeaddrinfo(res);
     client_freelist(ap);
     strncpy (response, "no servers available", len_response);
     return NOTOK;