< prev index next >
src/jdk.net/share/classes/jdk/net/Sockets.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -257,10 +257,25 @@
checkedReusePort = true;
}
return isReusePortAvailable;
}
+ private static volatile boolean isQuickAckAvailable;
+ private static volatile boolean checkedQuickAck;
+
+ /**
+ * Tells whether SO_QUICKACK is supported.
+ */
+ static boolean isQuickAckAvailable() {
+ if (!checkedQuickAck) {
+ Set<SocketOption<?>> s = new Socket().supportedOptions();
+ isQuickAckAvailable = s.contains(ExtendedSocketOptions.SO_QUICKACK);
+ checkedQuickAck = true;
+ }
+ return isQuickAckAvailable;
+ }
+
private static Map<Class<?>,Set<SocketOption<?>>> optionSets() {
Map<Class<?>,Set<SocketOption<?>>> options = new HashMap<>();
boolean flowsupported = PlatformSocketOptions.get().flowSupported();
boolean reuseportsupported = isReusePortAvailable();
// Socket
@@ -277,10 +292,13 @@
set.add(StandardSocketOptions.IP_TOS);
set.add(StandardSocketOptions.TCP_NODELAY);
if (flowsupported) {
set.add(ExtendedSocketOptions.SO_FLOW_SLA);
}
+ if (isQuickAckAvailable()) {
+ set.add(ExtendedSocketOptions.SO_QUICKACK);
+ }
set = Collections.unmodifiableSet(set);
options.put(Socket.class, set);
// ServerSocket
@@ -288,10 +306,13 @@
set.add(StandardSocketOptions.SO_RCVBUF);
set.add(StandardSocketOptions.SO_REUSEADDR);
if (reuseportsupported) {
set.add(StandardSocketOptions.SO_REUSEPORT);
}
+ if (isQuickAckAvailable()) {
+ set.add(ExtendedSocketOptions.SO_QUICKACK);
+ }
set.add(StandardSocketOptions.IP_TOS);
set = Collections.unmodifiableSet(set);
options.put(ServerSocket.class, set);
// DatagramSocket
< prev index next >