jdk/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c
changeset 12047 320a714614e9
parent 5506 202f599c92aa
child 12547 ae1b2051db5d
--- a/jdk/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c	Tue Mar 06 10:25:45 2012 +0800
+++ b/jdk/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c	Tue Mar 06 20:34:38 2012 +0000
@@ -35,7 +35,7 @@
 #include <string.h>
 #include <errno.h>
 
-#if __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #include <netinet/in.h>
 #endif
 
@@ -86,7 +86,7 @@
     rv = connect(fd, 0, 0);
 #endif
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     {
         int len;
         SOCKADDR sa;
@@ -96,17 +96,30 @@
 #ifdef AF_INET6
         if (ipv6_available()) {
             struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)&sa;
+#if defined(_ALLBSD_SOURCE)
+            him6->sin6_family = AF_INET6;
+#else
             him6->sin6_family = AF_UNSPEC;
+#endif
             len = sizeof(struct sockaddr_in6);
         } else
 #endif
         {
             struct sockaddr_in *him4 = (struct sockaddr_in*)&sa;
+#if defined(_ALLBSD_SOURCE)
+            him4->sin_family = AF_INET;
+#else
             him4->sin_family = AF_UNSPEC;
+#endif
             len = sizeof(struct sockaddr_in);
         }
 
         rv = connect(fd, (struct sockaddr *)&sa, len);
+
+#if defined(_ALLBSD_SOURCE)
+        if (rv < 0 && errno == EADDRNOTAVAIL)
+                rv = errno = 0;
+#endif
     }
 #endif