aboutsummaryrefslogtreecommitdiff
path: root/lib/connect.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2006-04-21 13:46:19 +0000
committerDaniel Stenberg <daniel@haxx.se>2006-04-21 13:46:19 +0000
commitdb03d4bdd0aa5b2eaef8fb0987310fe5c0ff0570 (patch)
tree40464558f59ce91404718b5061cba70eb369e85e /lib/connect.c
parent0ec96e427987e157dfbee57c016c30b671f336f5 (diff)
Ale Vesely fixed CURLOPT_INTERFACE when using a hostname
Diffstat (limited to 'lib/connect.c')
-rw-r--r--lib/connect.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/connect.c b/lib/connect.c
index f0865f47c..b3372f42a 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -100,6 +100,7 @@
#include "url.h" /* for Curl_safefree() */
#include "multiif.h"
#include "sockaddr.h" /* required for Curl_sockaddr_storage */
+#include "inet_ntop.h"
/* The last #include file should be: */
#include "memdebug.h"
@@ -288,8 +289,14 @@ static CURLcode bindlocal(struct connectdata *conn,
(void)Curl_wait_for_resolv(conn, &h);
if(h) {
- /* we know data->set.device is shorter than the myhost array */
- strcpy(myhost, data->set.device);
+ if(in == CURL_INADDR_NONE)
+ /* convert the resolved address, sizeof myhost >= INET_ADDRSTRLEN */
+ Curl_inet_ntop(h->addr->ai_addr->sa_family,
+ &((struct sockaddr_in*)h->addr->ai_addr)->sin_addr,
+ myhost, sizeof myhost);
+ else
+ /* we know data->set.device is shorter than the myhost array */
+ strcpy(myhost, data->set.device);
Curl_resolv_unlock(data, h);
}
}