Index: /pjproject/trunk/pjlib/include/pj/compat/socket.h
===================================================================
--- /pjproject/trunk/pjlib/include/pj/compat/socket.h	(revision 1607)
+++ /pjproject/trunk/pjlib/include/pj/compat/socket.h	(revision 1608)
@@ -69,4 +69,5 @@
 
 #   undef s_addr
+#   define PJ_SOCK_HAS_GETADDRINFO  1
 #endif	/* _MSC_VER */
 
Index: /pjproject/trunk/pjlib/include/pj/sock.h
===================================================================
--- /pjproject/trunk/pjlib/include/pj/sock.h	(revision 1607)
+++ /pjproject/trunk/pjlib/include/pj/sock.h	(revision 1608)
@@ -609,8 +609,28 @@
  *		for IPv4, PJ_INET6_ADDRSTRLEN characters for IPv6).
  *
- * @return	PJ_SUCCESS if conversion was successful..
+ * @return	PJ_SUCCESS if conversion was successful.
  */
 PJ_DECL(pj_status_t) pj_inet_ntop(int af, const void *src,
 				  char *dst, int size);
+
+/**
+ * Converts numeric address into its text string representation.
+ *
+ * @param af	Specify the family of the address. This can be PJ_AF_INET
+ *		or PJ_AF_INET6.
+ * @param src	Points to a buffer holding an IPv4 address if the af argument
+ *		is PJ_AF_INET, or an IPv6 address if the af argument is
+ *		PJ_AF_INET6; the address must be in network byte order.  
+ * @param dst	Points to a buffer where the function stores the resulting
+ *		text string; it shall not be NULL.  
+ * @param size	Specifies the size of this buffer, which shall be large 
+ *		enough to hold the text string (PJ_INET_ADDRSTRLEN characters
+ *		for IPv4, PJ_INET6_ADDRSTRLEN characters for IPv6).
+ *
+ * @return	The address string or NULL if failed.
+ */
+PJ_DECL(char*) pj_inet_ntop2(int af, const void *src,
+			     char *dst, int size);
+
 
 /**
@@ -708,7 +728,18 @@
  * @param addr	    Socket address.
  *
- * @return	    Port number, in host byte order.
+ * @return	    Length in bytes.
  */
 PJ_DECL(unsigned) pj_sockaddr_get_addr_len(const pj_sockaddr_t *addr);
+
+/**
+ * Get the socket address length, based on its address
+ * family. For PJ_AF_INET, the length will be sizeof(pj_sockaddr_in), and
+ * for PJ_AF_INET6, the length will be sizeof(pj_sockaddr_in6).
+ * 
+ * @param addr	    Socket address.
+ *
+ * @return	    Length in bytes.
+ */
+PJ_DECL(unsigned) pj_sockaddr_get_len(const pj_sockaddr_t *addr);
 
 /**
Index: /pjproject/trunk/pjlib/src/pj/addr_resolv_sock.c
===================================================================
--- /pjproject/trunk/pjlib/src/pj/addr_resolv_sock.c	(revision 1607)
+++ /pjproject/trunk/pjlib/src/pj/addr_resolv_sock.c	(revision 1608)
@@ -62,5 +62,5 @@
 #if defined(PJ_SOCK_HAS_GETADDRINFO) && PJ_SOCK_HAS_GETADDRINFO!=0
     char nodecopy[PJ_MAX_HOSTNAME];
-    struct addrinfo hint, *res;
+    struct addrinfo hint, *res, *orig_res;
     unsigned i;
     int rc;
@@ -85,8 +85,8 @@
 	return PJ_ERESOLVE;
 
+    orig_res = res;
+
     /* Enumerate each item in the result */
     for (i=0; i<*count && res; res=res->ai_next) {
-	int len;
-
 	/* Ignore unwanted address families */
 	if (af!=PJ_AF_UNSPEC && res->ai_family != af)
@@ -94,7 +94,11 @@
 
 	/* Store canonical name (possibly truncating the name) */
-	pj_ansi_strncpy(ai[i].ai_canonname, res->ai_canonname,
-		        sizeof(ai[i].ai_canonname));
-	ai[i].ai_canonname[sizeof(ai[i].ai_canonname)-1] = '\0';
+	if (res->ai_canonname) {
+	    pj_ansi_strncpy(ai[i].ai_canonname, res->ai_canonname,
+			    sizeof(ai[i].ai_canonname));
+	    ai[i].ai_canonname[sizeof(ai[i].ai_canonname)-1] = '\0';
+	} else {
+	    pj_ansi_strcpy(ai[i].ai_canonname, nodecopy);
+	}
 
 	/* Store address */
@@ -107,4 +111,6 @@
 
     *count = i;
+
+    freeaddrinfo(orig_res);
 
     /* Done */
Index: /pjproject/trunk/pjlib/src/pj/addr_resolv_symbian.cpp
===================================================================
--- /pjproject/trunk/pjlib/src/pj/addr_resolv_symbian.cpp	(revision 1607)
+++ /pjproject/trunk/pjlib/src/pj/addr_resolv_symbian.cpp	(revision 1608)
@@ -92,5 +92,5 @@
 
 	// Ignore if this is not the same address family
-	if (inetAddr.Family() != af) {
+	if (inetAddr.Family() != (unsigned)af) {
 	    resv.Next(nameEntry, reqStatus);
 	    User::WaitForRequest(reqStatus);
Index: /pjproject/trunk/pjlib/src/pj/ioqueue_symbian.cpp
===================================================================
--- /pjproject/trunk/pjlib/src/pj/ioqueue_symbian.cpp	(revision 1607)
+++ /pjproject/trunk/pjlib/src/pj/ioqueue_symbian.cpp	(revision 1608)
@@ -702,7 +702,7 @@
     	PJ_ASSERT_RETURN(addr && addrlen && *addrlen, PJ_EINVAL);
     	if (sock->GetAf() == PJ_AF_INET) {
-    	    PJ_ASSERT_RETURN(*addrlen >= sizeof(pj_sockaddr_in), PJ_EINVAL);
+    	    PJ_ASSERT_RETURN(*addrlen>=(int)sizeof(pj_sockaddr_in), PJ_EINVAL);
     	} else if (sock->GetAf() == PJ_AF_INET6) {
-    	    PJ_ASSERT_RETURN(*addrlen >= sizeof(pj_sockaddr_in6), PJ_EINVAL);
+    	    PJ_ASSERT_RETURN(*addrlen>=(int)sizeof(pj_sockaddr_in6), PJ_EINVAL);
     	}
     }
Index: /pjproject/trunk/pjlib/src/pj/ip_helper_symbian.cpp
===================================================================
--- /pjproject/trunk/pjlib/src/pj/ip_helper_symbian.cpp	(revision 1607)
+++ /pjproject/trunk/pjlib/src/pj/ip_helper_symbian.cpp	(revision 1608)
@@ -60,5 +60,5 @@
     	int namelen;
     	
-    	if (iAddress.Family() != af) {
+    	if (iAddress.Family() != (unsigned)af) {
     	    continue;
     	}
@@ -77,9 +77,4 @@
     
     return PJ_SUCCESS;
-    
-on_error:
-    rSock.Close();
-    *p_cnt = 0;
-    return PJ_RETURN_OS_ERROR(rc);
 }
 					
Index: /pjproject/trunk/pjlib/src/pj/os_symbian.h
===================================================================
--- /pjproject/trunk/pjlib/src/pj/os_symbian.h	(revision 1607)
+++ /pjproject/trunk/pjlib/src/pj/os_symbian.h	(revision 1608)
@@ -245,10 +245,10 @@
 	pj_addr.addr.sa_family = (pj_uint16_t)sym_addr.Family();
 	if (pj_addr.addr.sa_family == PJ_AF_INET) {
-	    PJ_ASSERT_RETURN(*addr_len >= sizeof(pj_sockaddr_in), PJ_ETOOSMALL);
+	    PJ_ASSERT_RETURN(*addr_len>=(int)sizeof(pj_sockaddr_in), PJ_ETOOSMALL);
 	    pj_addr.ipv4.sin_addr.s_addr = pj_htonl(sym_addr.Address());
 	    pj_addr.ipv4.sin_port = pj_htons((pj_uint16_t) sym_addr.Port());
 	    *addr_len = sizeof(pj_sockaddr_in);
 	} else if (pj_addr.addr.sa_family == PJ_AF_INET6) {
-	    PJ_ASSERT_RETURN(*addr_len >= sizeof(pj_sockaddr_in6), PJ_ETOOSMALL);
+	    PJ_ASSERT_RETURN(*addr_len>=(int)sizeof(pj_sockaddr_in6), PJ_ETOOSMALL);
 	    const TIp6Addr & ip6 = sym_addr.Ip6Address();
 	    pj_memcpy(&pj_addr.ipv6.sin6_addr, ip6.u.iAddr8, 16);
@@ -272,5 +272,5 @@
     {
     	if (pj_addr.addr.sa_family == PJ_AF_INET) {
-    	    PJ_ASSERT_RETURN(addrlen >= sizeof(pj_sockaddr_in), PJ_EINVAL);
+    	    PJ_ASSERT_RETURN(addrlen >= (int)sizeof(pj_sockaddr_in), PJ_EINVAL);
 	    sym_addr.Init(KAfInet);
     	    sym_addr.SetAddress((TUint32)pj_ntohl(pj_addr.ipv4.sin_addr.s_addr));
@@ -279,5 +279,5 @@
     	    TIp6Addr ip6;
     	
-    	    PJ_ASSERT_RETURN(addrlen >= sizeof(pj_sockaddr_in6), PJ_EINVAL);
+    	    PJ_ASSERT_RETURN(addrlen>=(int)sizeof(pj_sockaddr_in6), PJ_EINVAL);
     	    pj_memcpy(ip6.u.iAddr8, &pj_addr.ipv6.sin6_addr, 16);
     	    sym_addr.Init(KAfInet6);
Index: /pjproject/trunk/pjlib/src/pj/sock_common.c
===================================================================
--- /pjproject/trunk/pjlib/src/pj/sock_common.c	(revision 1607)
+++ /pjproject/trunk/pjlib/src/pj/sock_common.c	(revision 1608)
@@ -48,4 +48,16 @@
 
 /*
+ * Get text representation.
+ */
+PJ_DEF(char*) pj_inet_ntop2( int af, const void *src,
+			     char *dst, int size)
+{
+    pj_status_t status;
+
+    status = pj_inet_ntop(af, src, dst, size);
+    return (status==PJ_SUCCESS)? dst : NULL;
+}
+
+/*
  * Set the IP address of an IP socket address from string address, 
  * with resolving the host if necessary. The string address may be in a
@@ -254,4 +266,16 @@
 
 /*
+ * Get socket address length.
+ */
+PJ_DEF(unsigned) pj_sockaddr_get_len(const pj_sockaddr_t *addr)
+{
+    const pj_sockaddr *a = (const pj_sockaddr*) addr;
+    PJ_ASSERT_RETURN(a->addr.sa_family == PJ_AF_INET ||
+		     a->addr.sa_family == PJ_AF_INET6, PJ_EAFNOTSUP);
+    return a->addr.sa_family == PJ_AF_INET6 ?
+	    sizeof(pj_sockaddr_in6) : sizeof(pj_sockaddr_in);
+}
+
+/*
  * Set port number of pj_sockaddr_in
  */
@@ -270,6 +294,5 @@
     int af = addr->addr.sa_family;
 
-    PJ_ASSERT_ON_FAIL(af == PJ_AF_INET || af == PJ_AF_INET6, 
-		      PJ_EINVAL);
+    PJ_ASSERT_RETURN(af==PJ_AF_INET || af==PJ_AF_INET6, PJ_EINVAL);
 
     if (af == PJ_AF_INET6)
Index: /pjproject/trunk/pjlib/src/pj/sock_symbian.cpp
===================================================================
--- /pjproject/trunk/pjlib/src/pj/sock_symbian.cpp	(revision 1607)
+++ /pjproject/trunk/pjlib/src/pj/sock_symbian.cpp	(revision 1608)
@@ -525,5 +525,5 @@
 
     PJ_ASSERT_RETURN(sock != 0, PJ_EINVAL);
-    PJ_ASSERT_RETURN(addr && len >= sizeof(pj_sockaddr_in), PJ_EINVAL);
+    PJ_ASSERT_RETURN(addr && len>=(int)sizeof(pj_sockaddr_in), PJ_EINVAL);
 
     // Convert PJLIB's pj_sockaddr into Symbian's TInetAddr
@@ -676,5 +676,5 @@
 
     // Only supports AF_INET for now
-    PJ_ASSERT_RETURN(tolen >= sizeof(pj_sockaddr_in), PJ_EINVAL);
+    PJ_ASSERT_RETURN(tolen>=(int)sizeof(pj_sockaddr_in), PJ_EINVAL);
 
     TInetAddr inetAddr;
