Index: pjproject/trunk/aconfigure
===================================================================
--- pjproject/trunk/aconfigure	(revision 5402)
+++ pjproject/trunk/aconfigure	(revision 5403)
@@ -752,5 +752,4 @@
 oldincludedir
 includedir
-runstatedir
 localstatedir
 sharedstatedir
@@ -875,5 +874,4 @@
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
@@ -1128,13 +1126,4 @@
     silent=yes ;;
 
-  -runstatedir | --runstatedir | --runstatedi | --runstated \
-  | --runstate | --runstat | --runsta | --runst | --runs \
-  | --run | --ru | --r)
-    ac_prev=runstatedir ;;
-  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
-  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
-  | --run=* | --ru=* | --r=*)
-    runstatedir=$ac_optarg ;;
-
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
@@ -1274,5 +1263,5 @@
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir runstatedir
+		libdir localedir mandir
 do
   eval ac_val=\$$ac_var
@@ -1427,5 +1416,4 @@
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
-  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
@@ -5607,4 +5595,29 @@
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if IPV6_V6ONLY is available" >&5
+$as_echo_n "checking if IPV6_V6ONLY is available... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/socket.h>
+                                     #include <netinet/in.h>
+int
+main ()
+{
+int opt = IPV6_V6ONLY;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  $as_echo "#define PJ_SOCK_HAS_IPV6_V6ONLY 1" >>confdefs.h
+
+		   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if SO_ERROR is available" >&5
 $as_echo_n "checking if SO_ERROR is available... " >&6; }
Index: pjproject/trunk/aconfigure.ac
===================================================================
--- pjproject/trunk/aconfigure.ac	(revision 5402)
+++ pjproject/trunk/aconfigure.ac	(revision 5403)
@@ -341,4 +341,13 @@
 		    		   [socklen_t xxx = 0;])],
 		  [AC_DEFINE(PJ_HAS_SOCKLEN_T,1)
+		   AC_MSG_RESULT(yes)],
+		  AC_MSG_RESULT(no))
+
+dnl # Determine if IPV6_V6ONLY is available
+AC_MSG_CHECKING([if IPV6_V6ONLY is available])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>
+                                     #include <netinet/in.h>]],
+		    		   [int opt = IPV6_V6ONLY;])],
+		  [AC_DEFINE(PJ_SOCK_HAS_IPV6_V6ONLY,1)
 		   AC_MSG_RESULT(yes)],
 		  AC_MSG_RESULT(no))
Index: pjproject/trunk/pjlib/include/pj/compat/os_auto.h.in
===================================================================
--- pjproject/trunk/pjlib/include/pj/compat/os_auto.h.in	(revision 5402)
+++ pjproject/trunk/pjlib/include/pj/compat/os_auto.h.in	(revision 5403)
@@ -84,4 +84,5 @@
 #undef PJ_HAS_WS2TCPIP_H
 
+#undef PJ_SOCK_HAS_IPV6_V6ONLY
 #undef PJ_SOCK_HAS_INET_ATON
 #undef PJ_SOCK_HAS_INET_PTON
Index: pjproject/trunk/pjlib/src/pj/sock_bsd.c
===================================================================
--- pjproject/trunk/pjlib/src/pj/sock_bsd.c	(revision 5402)
+++ pjproject/trunk/pjlib/src/pj/sock_bsd.c	(revision 5403)
@@ -540,4 +540,10 @@
 			       &val, sizeof(val));
 	}
+#if defined(PJ_SOCK_HAS_IPV6_V6ONLY) && PJ_SOCK_HAS_IPV6_V6ONLY != 0
+	if (af == PJ_AF_INET6) {
+	    pj_sock_setsockopt(*sock, PJ_SOL_IPV6, IPV6_V6ONLY,
+			       &val, sizeof(val));
+	}
+#endif
 #if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \
     PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0
