< prev index next >

src/java.base/share/classes/sun/net/ext/ExtendedSocketOptions.java

Print this page

        

*** 46,72 **** --- 46,80 ---- private final Set<SocketOption<?>> options; private final Set<SocketOption<?>> datagramOptions; private final Set<SocketOption<?>> clientStreamOptions; private final Set<SocketOption<?>> serverStreamOptions; + private final Set<SocketOption<?>> unixOptions; /** Tells whether or not the option is supported. */ public final boolean isOptionSupported(SocketOption<?> option) { return options().contains(option); } /** Return the, possibly empty, set of extended socket options available. */ public final Set<SocketOption<?>> options() { return options; } + /** Return the, possibly empty, set of extended socket options available. */ + public final Set<SocketOption<?>> unixOptions() { return unixOptions; } + /** * Returns the (possibly empty) set of extended socket options for * stream-oriented listening sockets. */ public static Set<SocketOption<?>> serverSocketOptions() { return getInstance().options0(SOCK_STREAM, true); } + public static Set<SocketOption<?>> unixSocketOptions() { + return getInstance().unixOptions(); + } + /** * Returns the (possibly empty) set of extended socket options for * stream-oriented connecting sockets. */ public static Set<SocketOption<?>> clientSocketOptions() {
*** 80,96 **** public static Set<SocketOption<?>> datagramSocketOptions() { return getInstance().options0(SOCK_DGRAM, false); } private static boolean isDatagramOption(SocketOption<?> option) { ! return !option.name().startsWith("TCP_"); } private static boolean isStreamOption(SocketOption<?> option, boolean server) { if (server && "SO_FLOW_SLA".equals(option.name())) { return false; } else { return !option.name().startsWith("UDP_"); } } private Set<SocketOption<?>> options0(short type, boolean server) { --- 88,111 ---- public static Set<SocketOption<?>> datagramSocketOptions() { return getInstance().options0(SOCK_DGRAM, false); } private static boolean isDatagramOption(SocketOption<?> option) { ! return !option.name().startsWith("TCP_") && !isUnixOption(option); ! } ! ! private static boolean isUnixOption(SocketOption<?> option) { ! return option.name().equals("SO_PEERCRED"); } private static boolean isStreamOption(SocketOption<?> option, boolean server) { if (server && "SO_FLOW_SLA".equals(option.name())) { return false; } else { + if (isUnixOption(option)) { + return false; + } return !option.name().startsWith("UDP_"); } } private Set<SocketOption<?>> options0(short type, boolean server) {
*** 120,143 **** --- 135,163 ---- protected ExtendedSocketOptions(Set<SocketOption<?>> options) { this.options = options; var datagramOptions = new HashSet<SocketOption<?>>(); var serverStreamOptions = new HashSet<SocketOption<?>>(); var clientStreamOptions = new HashSet<SocketOption<?>>(); + var unixOptions = new HashSet<SocketOption<?>>(); for (var option : options) { if (isDatagramOption(option)) { datagramOptions.add(option); } if (isStreamOption(option, true)) { serverStreamOptions.add(option); } if (isStreamOption(option, false)) { clientStreamOptions.add(option); } + if (isUnixOption(option)) { + unixOptions.add(option); + } } this.datagramOptions = Set.copyOf(datagramOptions); this.serverStreamOptions = Set.copyOf(serverStreamOptions); this.clientStreamOptions = Set.copyOf(clientStreamOptions); + this.unixOptions = Set.copyOf(unixOptions); } private static volatile ExtendedSocketOptions instance; public static final ExtendedSocketOptions getInstance() { return instance; }
< prev index next >