summaryrefslogtreecommitdiffstats
path: root/usr.bin/whois
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/whois')
-rw-r--r--usr.bin/whois/whois.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.bin/whois/whois.c b/usr.bin/whois/whois.c
index 3e31a65..d4452c0 100644
--- a/usr.bin/whois/whois.c
+++ b/usr.bin/whois/whois.c
@@ -220,12 +220,17 @@ whois(name, res, flags)
size_t len;
int s, nomatch;
- s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
- if (s < 0) {
- err(EX_OSERR, "socket");
+ for (; res; res = res->ai_next) {
+ s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (s < 0) {
+ continue;
+ }
+ if (connect(s, res->ai_addr, res->ai_addrlen) == 0) {
+ break;
+ }
+ close(s);
}
-
- if (connect(s, res->ai_addr, res->ai_addrlen) < 0) {
+ if (res == NULL) {
err(EX_OSERR, "connect");
}
OpenPOWER on IntegriCloud