From 2ed8b31a1133d4e25b78dce44f5f1c95abbc4e7a Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Thu, 4 Apr 2013 01:31:51 -0700 Subject: [PATCH] ipv6 --- common/os_calls.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/common/os_calls.c b/common/os_calls.c index ea122552..af54facf 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -542,16 +542,24 @@ g_tcp_connect(int sck, const char *address, const char *port) * available IPv4-mapped addresses in case the target * host does not have a true IPv6 address: */ + p.ai_socktype = SOCK_STREAM; + p.ai_protocol = IPPROTO_TCP; #if !defined(NO_ARPA_INET_H_IP6) p.ai_flags = AI_ADDRCONFIG | AI_V4MAPPED; p.ai_family = AF_INET6; + if (g_strcmp(address, "127.0.0.1") == 0) + { + res = getaddrinfo("::1", port, &p, &h); + } + else + { + res = getaddrinfo(address, port, &p, &h); + } #else p.ai_flags = AI_ADDRCONFIG; p.ai_family = AF_INET; -#endif - p.ai_socktype = SOCK_STREAM; - p.ai_protocol = IPPROTO_TCP; res = getaddrinfo(address, port, &p, &h); +#endif if (res > -1) { if (h != NULL)