From 3d29bda9f836d21b35110d6a005d56b6931bee6a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 1 May 2008 21:34:34 +0000 Subject: - Bart Whiteley provided a patch that made libcurl work properly when an app uses the CURLOPT_OPENSOCKETFUNCTION callback to create a unix domain socket to a http server. --- lib/connect.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/connect.c b/lib/connect.c index 063556315..dcccfe4d2 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -34,6 +34,9 @@ #ifdef HAVE_NETINET_IN_H #include /* may need it */ #endif +#ifdef HAVE_SYS_UN_H +#include /* for sockaddr_un */ +#endif #ifdef HAVE_NETINET_TCP_H #include /* for TCP_NODELAY */ #endif @@ -766,13 +769,24 @@ singleipconnect(struct connectdata *conn, /* FIXME: do we have Curl_printable_address-like with struct sockaddr* as argument? */ - iptoprint = &((const struct sockaddr_in*)(&addr->addr))->sin_addr; +#if defined(HAVE_SYS_UN_H) && defined(AF_UNIX) + if(addr->family==AF_UNIX) + infof(data, " Trying %s... ", + ((const struct sockaddr_un*)(&addr->addr))->sun_path); + else +#endif + { #ifdef ENABLE_IPV6 - if(addr->family==AF_INET6) - iptoprint= &((const struct sockaddr_in6*)(&addr->addr))->sin6_addr; + if(addr->family==AF_INET6) + iptoprint= &((const struct sockaddr_in6*)(&addr->addr))->sin6_addr; + else #endif - Curl_inet_ntop(addr->family, iptoprint, addr_buf, sizeof(addr_buf)); - infof(data, " Trying %s... ", addr_buf); + iptoprint = &((const struct sockaddr_in*)(&addr->addr))->sin_addr; + + if(Curl_inet_ntop(addr->family, iptoprint, addr_buf, + sizeof(addr_buf)) != NULL) + infof(data, " Trying %s... ", addr_buf); + } if(data->set.tcp_nodelay) tcpnodelay(conn, sockfd); -- cgit v1.2.3