From 2297eca103307e077837951f33d06d08a19559d3 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 19 Sep 2003 15:16:47 +0000 Subject: Added CURLOPT_IPRESOLVE support --- lib/hostip.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'lib/hostip.c') diff --git a/lib/hostip.c b/lib/hostip.c index 3f465a0d0..1a881cf9b 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -653,7 +653,7 @@ static Curl_addrinfo *my_getaddrinfo(struct connectdata *conn, struct addrinfo hints, *res; int error; char sbuf[NI_MAXSERV]; - int s, pf = PF_UNSPEC; + int s, pf; struct SessionHandle *data = conn->data; *waitp=0; /* don't wait, we have the response now */ @@ -665,11 +665,27 @@ static Curl_addrinfo *my_getaddrinfo(struct connectdata *conn, * when PF_UNSPEC is used, so thus we switch to a mere PF_INET lookup if * the stack seems to be a non-ipv6 one. */ pf = PF_INET; - else + else { /* This seems to be an IPv6-capable stack, use PF_UNSPEC for the widest * possible checks. And close the socket again. */ sclose(s); + + /* + * Check if a more limited name resolve has been requested. + */ + switch(data->set.ip_version) { + case CURL_IPRESOLVE_V4: + pf = PF_INET; + break; + case CURL_IPRESOLVE_V6: + pf = PF_INET6; + break; + default: + pf = PF_UNSPEC; + break; + } + } memset(&hints, 0, sizeof(hints)); hints.ai_family = pf; -- cgit v1.2.3