jdk/src/java.base/share/classes/sun/nio/ch/Net.java
changeset 36115 0676e37a0b9c
parent 34774 03b4e6dc367b
child 37593 824750ada3d6
equal deleted inserted replaced
36114:a5ed9456c9be 36115:0676e37a0b9c
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    54 
    54 
    55     // -- Miscellaneous utilities --
    55     // -- Miscellaneous utilities --
    56 
    56 
    57     private static volatile boolean checkedIPv6;
    57     private static volatile boolean checkedIPv6;
    58     private static volatile boolean isIPv6Available;
    58     private static volatile boolean isIPv6Available;
       
    59     private static volatile boolean checkedReusePort;
       
    60     private static volatile boolean isReusePortAvailable;
    59 
    61 
    60     /**
    62     /**
    61      * Tells whether dual-IPv4/IPv6 sockets should be used.
    63      * Tells whether dual-IPv4/IPv6 sockets should be used.
    62      */
    64      */
    63     static boolean isIPv6Available() {
    65     static boolean isIPv6Available() {
    64         if (!checkedIPv6) {
    66         if (!checkedIPv6) {
    65             isIPv6Available = isIPv6Available0();
    67             isIPv6Available = isIPv6Available0();
    66             checkedIPv6 = true;
    68             checkedIPv6 = true;
    67         }
    69         }
    68         return isIPv6Available;
    70         return isIPv6Available;
       
    71     }
       
    72 
       
    73     /**
       
    74      * Tells whether SO_REUSEPORT is supported.
       
    75      */
       
    76     static boolean isReusePortAvailable() {
       
    77         if (!checkedReusePort) {
       
    78             isReusePortAvailable = isReusePortAvailable0();
       
    79             checkedReusePort = true;
       
    80         }
       
    81         return isReusePortAvailable;
    69     }
    82     }
    70 
    83 
    71     /**
    84     /**
    72      * Returns true if exclusive binding is on
    85      * Returns true if exclusive binding is on
    73      */
    86      */
   386     }
   399     }
   387 
   400 
   388     // -- Socket operations --
   401     // -- Socket operations --
   389 
   402 
   390     private static native boolean isIPv6Available0();
   403     private static native boolean isIPv6Available0();
       
   404 
       
   405     private static native boolean isReusePortAvailable0();
   391 
   406 
   392     /*
   407     /*
   393      * Returns 1 for Windows and -1 for Solaris/Linux/Mac OS
   408      * Returns 1 for Windows and -1 for Solaris/Linux/Mac OS
   394      */
   409      */
   395     private static native int isExclusiveBindAvailable();
   410     private static native int isExclusiveBindAvailable();