Skip to content

Commit

Permalink
getaddrinfo same as commit e08d420
Browse files Browse the repository at this point in the history
  • Loading branch information
mirabilos committed Apr 14, 2023
1 parent ff4c88d commit 8a299c5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions ws2/client/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,16 @@ do_resolve(const char *host, const char *service)
ap->ai_family = AF_UNSPEC;
ap->ai_socktype = SOCK_DGRAM;
ap->ai_flags = AI_ADDRCONFIG; /* note lack of AI_V4MAPPED */
switch ((i = getaddrinfo(host, service, ap, &ai))) {
#if !(defined(_WIN32) || defined(WIN32))
case EAI_SYSTEM:
err(1, "getaddrinfo");
i = getaddrinfo(host, service, ap, &ai);
if (i) {
#if defined(_WIN32) || defined(WIN32)
ws2err(1, "getaddrinfo");
#else
if (i == EAI_SYSTEM)
err(1, "getaddrinfo");
else
errx(1, "%s: %s", "getaddrinfo", gai_strerror(i));
#endif
default:
errx(1, "%s returned %s", "getaddrinfo", gai_strerror(i));
case 0:
break;
}
free(ap);

Expand All @@ -157,8 +158,7 @@ do_resolve(const char *host, const char *service)
if (i == EAI_SYSTEM)
warn("getnameinfo");
else
warnx("%s returned %s", "getnameinfo",
gai_strerror(i));
warnx("%s: %s", "getnameinfo", gai_strerror(i));
#endif
fprintf(stderr, "Trying (unknown)...");
} else
Expand Down
20 changes: 10 additions & 10 deletions ws2/server/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ revlookup(const struct sockaddr *addr, socklen_t addrlen)
if (i == EAI_SYSTEM)
warn("getnameinfo");
else
warnx("%s returned %s", "getnameinfo",
gai_strerror(i));
warnx("%s: %s", "getnameinfo", gai_strerror(i));
#endif
memcpy(buf, "(unknown)", sizeof("(unknown)"));
} else
Expand All @@ -174,15 +173,16 @@ do_resolve(const char *host, const char *service)
ap->ai_family = AF_UNSPEC;
ap->ai_socktype = SOCK_DGRAM;
ap->ai_flags = AI_ADDRCONFIG | AI_PASSIVE; /* no AI_V4MAPPED either */
switch ((i = getaddrinfo(host, service, ap, &ai))) {
#if !(defined(_WIN32) || defined(WIN32))
case EAI_SYSTEM:
err(1, "getaddrinfo");
i = getaddrinfo(host, service, ap, &ai);
if (i) {
#if defined(_WIN32) || defined(WIN32)
ws2err(1, "getaddrinfo");
#else
if (i == EAI_SYSTEM)
err(1, "getaddrinfo");
else
errx(1, "%s: %s", "getaddrinfo", gai_strerror(i));
#endif
default:
errx(1, "%s returned %s", "getaddrinfo", gai_strerror(i));
case 0:
break;
}
free(ap);

Expand Down

0 comments on commit 8a299c5

Please sign in to comment.