From 8888e65159e8b4c46c487a1f7a3ed9a036f43f1e Mon Sep 17 00:00:00 2001 From: ume Date: Fri, 1 Jun 2001 13:43:20 +0000 Subject: Do retry next entry in addrinfo during connect. MFC after: 1 week --- usr.bin/whois/whois.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'usr.bin/whois') 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"); } -- cgit v1.1