-#ifdef WORKING_IPV6
- hints.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ALL;
- hints.ai_family = AF_UNSPEC;
-#else
- hints.ai_flags = AI_CANONNAME;
- hints.ai_family = AF_INET;
-#endif
- hints.ai_socktype = 0;
- hints.ai_protocol = 0;
- hints.ai_addrlen = 0;
- hints.ai_addr = NULL;
- hints.ai_canonname = NULL;
- hints.ai_next = NULL;
- res = getaddrinfo("localhost", NULL, &hints, &gaires);
-#ifdef WORKING_IPV6
- if (res != 0) {
- hints.ai_flags = AI_CANONNAME;
- hints.ai_family = AF_UNSPEC;
- res = getaddrinfo("localhost", NULL, &hints, &gaires);
- }
-#endif
- if (res != 0) {
- errstr = newvstralloc(errstr,
- _("could not resolve localhost: "),
- gai_strerror(res), NULL);
+ if ((res = resolve_hostname("localhost", 0, NULL, NULL) != 0)) {
+ errstr = newvstrallocf(errstr,
+ _("could not resolve localhost: %s"),
+ gai_strerror(res));