< prev index next >

src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c

Print this page

        

@@ -888,10 +888,18 @@
     if (mallocedPacket) {
         free(fullPacket);
     }
 }
 
+static int socket0(int domain, int type, int protocol) {
+    if (domain == AF_INET) {
+        errno = EAFNOSUPPORT;
+        return -1;
+    }
+    return socket(domain, type, protocol);
+}
+
 /*
  * Class:     java_net_PlainDatagramSocketImpl
  * Method:    datagramSocketCreate
  * Signature: ()V
  */

@@ -907,11 +915,11 @@
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                         "Socket closed");
         return;
     }
 
-    if ((fd = socket(domain, SOCK_DGRAM, 0)) == -1) {
+    if ((fd = socket0(domain, SOCK_DGRAM, 0)) == -1) {
         JNU_ThrowByNameWithMessageAndLastError
             (env, JNU_JAVANETPKG "SocketException", "Error creating socket");
         return;
     }
 
< prev index next >