< prev index next >

src/java.base/share/classes/jdk/net/Sockets.java

Print this page

        

@@ -252,10 +252,11 @@
         }
     }
 
     private static void initOptionSets() {
         boolean flowsupported = ExtendedOptionsImpl.flowSupported();
+        boolean reuseportsupported = ExtendedOptionsImpl.reuseportSupported();
 
         // Socket
 
         Set<SocketOption<?>> set = new HashSet<>();
         set.add(StandardSocketOptions.SO_KEEPALIVE);

@@ -266,19 +267,25 @@
         set.add(StandardSocketOptions.IP_TOS);
         set.add(StandardSocketOptions.TCP_NODELAY);
         if (flowsupported) {
             set.add(ExtendedSocketOptions.SO_FLOW_SLA);
         }
+        if (reuseportsupported) {
+            set.add(ExtendedSocketOptions.SO_REUSEPORT);
+        }
         set = Collections.unmodifiableSet(set);
         options.put(Socket.class, set);
 
         // ServerSocket
 
         set = new HashSet<>();
         set.add(StandardSocketOptions.SO_RCVBUF);
         set.add(StandardSocketOptions.SO_REUSEADDR);
         set.add(StandardSocketOptions.IP_TOS);
+        if (reuseportsupported) {
+            set.add(ExtendedSocketOptions.SO_REUSEPORT);
+        }
         set = Collections.unmodifiableSet(set);
         options.put(ServerSocket.class, set);
 
         // DatagramSocket
 

@@ -288,10 +295,13 @@
         set.add(StandardSocketOptions.SO_REUSEADDR);
         set.add(StandardSocketOptions.IP_TOS);
         if (flowsupported) {
             set.add(ExtendedSocketOptions.SO_FLOW_SLA);
         }
+        if (reuseportsupported) {
+            set.add(ExtendedSocketOptions.SO_REUSEPORT);
+        }
         set = Collections.unmodifiableSet(set);
         options.put(DatagramSocket.class, set);
 
         // MulticastSocket
 

@@ -304,9 +314,12 @@
         set.add(StandardSocketOptions.IP_MULTICAST_TTL);
         set.add(StandardSocketOptions.IP_MULTICAST_LOOP);
         if (flowsupported) {
             set.add(ExtendedSocketOptions.SO_FLOW_SLA);
         }
+        if (reuseportsupported) {
+            set.add(ExtendedSocketOptions.SO_REUSEPORT);
+        }
         set = Collections.unmodifiableSet(set);
         options.put(MulticastSocket.class, set);
     }
 }
< prev index next >