Index: pjproject/trunk/pjlib/include/pj/compat/os_auto.h.in
===================================================================
--- pjproject/trunk/pjlib/include/pj/compat/os_auto.h.in	(revision 3542)
+++ pjproject/trunk/pjlib/include/pj/compat/os_auto.h.in	(revision 3543)
@@ -176,7 +176,7 @@
 #    if TARGET_OS_IPHONE
 #	include "Availability.h"
+	/* Use CFHost API for pj_getaddrinfo() (see ticket #1246) */
+#	define PJ_GETADDRINFO_USE_CFHOST 1
 #    	ifdef __IPHONE_4_0
- 	    /* Append ".local" suffix to the system's hostname? (see ticket #1104) */
-#	    define PJ_GETHOSTNAME_APPEND_LOCAL_SUFFIX 		1
  	    /* Is multitasking support available?  (see ticket #1107) */
 #	    define PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT 	1
Index: pjproject/trunk/pjlib/src/pj/addr_resolv_sock.c
===================================================================
--- pjproject/trunk/pjlib/src/pj/addr_resolv_sock.c	(revision 3542)
+++ pjproject/trunk/pjlib/src/pj/addr_resolv_sock.c	(revision 3543)
@@ -25,4 +25,8 @@
 #include <pj/compat/socket.h>
 
+#if defined(PJ_GETADDRINFO_USE_CFHOST) && PJ_GETADDRINFO_USE_CFHOST!=0
+#   include <CoreFoundation/CFString.h>
+#   include <CFNetwork/CFHost.h>
+#endif
 
 PJ_DEF(pj_status_t) pj_gethostbyname(const pj_str_t *hostname, pj_hostent *phe)
@@ -63,8 +67,14 @@
 #if defined(PJ_SOCK_HAS_GETADDRINFO) && PJ_SOCK_HAS_GETADDRINFO!=0
     char nodecopy[PJ_MAX_HOSTNAME];
-    struct addrinfo hint, *res, *orig_res;
     pj_bool_t has_addr = PJ_FALSE;
     unsigned i;
+#if defined(PJ_GETADDRINFO_USE_CFHOST) && PJ_GETADDRINFO_USE_CFHOST!=0
+    CFStringRef hostname;
+    CFHostRef hostRef;
+    pj_status_t status = PJ_SUCCESS;
+#else
     int rc;
+    struct addrinfo hint, *res, *orig_res;
+#endif
 
     PJ_ASSERT_RETURN(nodename && count && *count && ai, PJ_EINVAL);
@@ -106,4 +116,51 @@
     nodecopy[nodename->slen] = '\0';
 
+#if defined(PJ_GETADDRINFO_USE_CFHOST) && PJ_GETADDRINFO_USE_CFHOST!=0
+    hostname =  CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, nodecopy,
+						kCFStringEncodingASCII,
+						kCFAllocatorNull);
+    hostRef = CFHostCreateWithName(kCFAllocatorDefault, hostname);
+    if (CFHostStartInfoResolution(hostRef, kCFHostAddresses, nil)) {
+	CFArrayRef addrRef = CFHostGetAddressing(hostRef, nil);
+	i = 0;
+	if (addrRef != nil) {
+	    CFIndex idx, naddr;
+	    
+	    naddr = CFArrayGetCount(addrRef);
+	    for (idx = 0; idx < naddr && i < *count; idx++) {
+		struct sockaddr *addr;
+		
+		addr = (struct sockaddr *)
+		       CFDataGetBytePtr(CFArrayGetValueAtIndex(addrRef, idx));
+		/* This should not happen. */
+		pj_assert(addr);
+		
+		/* Ignore unwanted address families */
+		if (af!=PJ_AF_UNSPEC && addr->sa_family != af)
+		    continue;
+
+		/* Store canonical name */
+		pj_ansi_strcpy(ai[i].ai_canonname, nodecopy);
+		
+		/* Store address */
+		PJ_ASSERT_ON_FAIL(sizeof(*addr) <= sizeof(pj_sockaddr),
+				  continue);
+		pj_memcpy(&ai[i].ai_addr, addr, sizeof(*addr));
+		PJ_SOCKADDR_RESET_LEN(&ai[i].ai_addr);
+		
+		i++;
+	    }
+	}
+	
+	*count = i;
+    } else {
+	status = PJ_ERESOLVE;
+    }
+    
+    CFRelease(hostRef);
+    CFRelease(hostname);
+    
+    return status;
+#else
     /* Call getaddrinfo() */
     pj_bzero(&hint, sizeof(hint));
@@ -146,4 +203,5 @@
     /* Done */
     return PJ_SUCCESS;
+#endif
 
 #else	/* PJ_SOCK_HAS_GETADDRINFO */
Index: pjproject/trunk/pjlib/src/pj/sock_bsd.c
===================================================================
--- pjproject/trunk/pjlib/src/pj/sock_bsd.c	(revision 3542)
+++ pjproject/trunk/pjlib/src/pj/sock_bsd.c	(revision 3543)
@@ -457,21 +457,4 @@
 	} else {
             hostname.slen = strlen(buf);
-#if defined(PJ_GETHOSTNAME_APPEND_LOCAL_SUFFIX) && \
-    PJ_GETHOSTNAME_APPEND_LOCAL_SUFFIX!=0
-            {
-                const pj_str_t suffix = {".local", 6};
-
-                if (hostname.slen < suffix.slen ||
-                    pj_ansi_strnicmp(hostname.ptr + hostname.slen -
-                                     suffix.slen, suffix.ptr, suffix.slen))
-                {
-                    if (hostname.slen + suffix.slen + 1 < sizeof(buf))
-                        pj_strcat(&hostname, &suffix);
-                    else
-                        hostname.slen = 0;
-                    hostname.ptr[hostname.slen] = '\0';
-                }
-            }
-#endif
 	}
     }
Index: pjproject/trunk/pjnath/src/pjturn-client/client_main.c
===================================================================
--- pjproject/trunk/pjnath/src/pjturn-client/client_main.c	(revision 3542)
+++ pjproject/trunk/pjnath/src/pjturn-client/client_main.c	(revision 3543)
@@ -186,5 +186,5 @@
 
 
-static int shutdown()
+static int client_shutdown()
 {
     unsigned i;
@@ -626,5 +626,5 @@
 
 on_return:
-    shutdown();
+    client_shutdown();
     return status ? 1 : 0;
 }
