< prev index next >

src/java.base/share/classes/sun/nio/ch/Net.java

Print this page
rev 59383 : [mq]: final
   1 /*
   2  * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 478         if (type == Integer.class) {
 479             return Integer.valueOf(value);
 480         } else {
 481             return (value == 0) ? Boolean.FALSE : Boolean.TRUE;
 482         }
 483     }
 484 
 485     public static boolean isFastTcpLoopbackRequested() {
 486         String loopbackProp = GetPropertyAction
 487                 .privilegedGetProperty("jdk.net.useFastTcpLoopback", "false");
 488         return loopbackProp.isEmpty() ? true : Boolean.parseBoolean(loopbackProp);
 489     }
 490 
 491     // -- Socket operations --
 492 
 493     private static native boolean isIPv6Available0();
 494 
 495     private static native boolean isReusePortAvailable0();
 496 
 497     /*
 498      * Returns 1 for Windows and -1 for Solaris/Linux/Mac OS
 499      */
 500     private static native int isExclusiveBindAvailable();
 501 
 502     private static native boolean shouldSetBothIPv4AndIPv6Options0();
 503 
 504     private static native boolean canIPv6SocketJoinIPv4Group0();
 505 
 506     private static native boolean canJoin6WithIPv4Group0();
 507 
 508     private static native boolean canUseIPv6OptionsWithIPv4LocalAddress0();
 509 
 510     static FileDescriptor socket(boolean stream) throws IOException {
 511         return socket(UNSPEC, stream);
 512     }
 513 
 514     static FileDescriptor socket(ProtocolFamily family, boolean stream) throws IOException {
 515         boolean preferIPv6 = isIPv6Available() &&
 516             (family != StandardProtocolFamily.INET);
 517         return IOUtil.newFD(socket0(preferIPv6, stream, false, fastLoopback));
 518     }


   1 /*
   2  * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 478         if (type == Integer.class) {
 479             return Integer.valueOf(value);
 480         } else {
 481             return (value == 0) ? Boolean.FALSE : Boolean.TRUE;
 482         }
 483     }
 484 
 485     public static boolean isFastTcpLoopbackRequested() {
 486         String loopbackProp = GetPropertyAction
 487                 .privilegedGetProperty("jdk.net.useFastTcpLoopback", "false");
 488         return loopbackProp.isEmpty() ? true : Boolean.parseBoolean(loopbackProp);
 489     }
 490 
 491     // -- Socket operations --
 492 
 493     private static native boolean isIPv6Available0();
 494 
 495     private static native boolean isReusePortAvailable0();
 496 
 497     /*
 498      * Returns 1 for Windows and -1 for Linux/Mac OS
 499      */
 500     private static native int isExclusiveBindAvailable();
 501 
 502     private static native boolean shouldSetBothIPv4AndIPv6Options0();
 503 
 504     private static native boolean canIPv6SocketJoinIPv4Group0();
 505 
 506     private static native boolean canJoin6WithIPv4Group0();
 507 
 508     private static native boolean canUseIPv6OptionsWithIPv4LocalAddress0();
 509 
 510     static FileDescriptor socket(boolean stream) throws IOException {
 511         return socket(UNSPEC, stream);
 512     }
 513 
 514     static FileDescriptor socket(ProtocolFamily family, boolean stream) throws IOException {
 515         boolean preferIPv6 = isIPv6Available() &&
 516             (family != StandardProtocolFamily.INET);
 517         return IOUtil.newFD(socket0(preferIPv6, stream, false, fastLoopback));
 518     }


< prev index next >