< prev index next >

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

Print this page
rev 54103 : imported patch ipv6-only-build


 900                                                            jobject this) {
 901     jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
 902     int arg, fd, t = 1;
 903     char tmpbuf[1024];
 904     int domain = ipv6_available() ? AF_INET6 : AF_INET;
 905 
 906     if (IS_NULL(fdObj)) {
 907         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
 908                         "Socket closed");
 909         return;
 910     }
 911 
 912     if ((fd = socket(domain, SOCK_DGRAM, 0)) == -1) {
 913         JNU_ThrowByNameWithMessageAndLastError
 914             (env, JNU_JAVANETPKG "SocketException", "Error creating socket");
 915         return;
 916     }
 917 
 918     /* Disable IPV6_V6ONLY to ensure dual-socket support */
 919     if (domain == AF_INET6) {
 920         arg = 0;
 921         if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&arg,
 922                        sizeof(int)) < 0) {
 923             NET_ThrowNew(env, errno, "cannot set IPPROTO_IPV6");
 924             close(fd);
 925             return;
 926         }
 927     }
 928 
 929 #ifdef __APPLE__
 930     arg = 65507;
 931     if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF,
 932                    (char *)&arg, sizeof(arg)) < 0) {
 933         getErrorString(errno, tmpbuf, sizeof(tmpbuf));
 934         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", tmpbuf);
 935         close(fd);
 936         return;
 937     }
 938     if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF,
 939                    (char *)&arg, sizeof(arg)) < 0) {
 940         getErrorString(errno, tmpbuf, sizeof(tmpbuf));




 900                                                            jobject this) {
 901     jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
 902     int arg, fd, t = 1;
 903     char tmpbuf[1024];
 904     int domain = ipv6_available() ? AF_INET6 : AF_INET;
 905 
 906     if (IS_NULL(fdObj)) {
 907         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
 908                         "Socket closed");
 909         return;
 910     }
 911 
 912     if ((fd = socket(domain, SOCK_DGRAM, 0)) == -1) {
 913         JNU_ThrowByNameWithMessageAndLastError
 914             (env, JNU_JAVANETPKG "SocketException", "Error creating socket");
 915         return;
 916     }
 917 
 918     /* Disable IPV6_V6ONLY to ensure dual-socket support */
 919     if (domain == AF_INET6) {
 920         arg = 1;   // ENABLE
 921         if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&arg,
 922                        sizeof(int)) < 0) {
 923             NET_ThrowNew(env, errno, "cannot set IPPROTO_IPV6");
 924             close(fd);
 925             return;
 926         }
 927     }
 928 
 929 #ifdef __APPLE__
 930     arg = 65507;
 931     if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF,
 932                    (char *)&arg, sizeof(arg)) < 0) {
 933         getErrorString(errno, tmpbuf, sizeof(tmpbuf));
 934         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", tmpbuf);
 935         close(fd);
 936         return;
 937     }
 938     if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF,
 939                    (char *)&arg, sizeof(arg)) < 0) {
 940         getErrorString(errno, tmpbuf, sizeof(tmpbuf));


< prev index next >