< prev index next >

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

Print this page




 486             throw new UnsupportedOperationException("'" + name + "' not supported");
 487 
 488         try {
 489             begin();
 490             if (name == StandardSocketOptions.SO_REUSEADDR &&
 491                     Net.useExclusiveBind())
 492             {
 493                 // SO_REUSEADDR emulated when using exclusive bind
 494                 return (T)Boolean.valueOf(isReuseAddress);
 495             }
 496             return (T) Net.getSocketOption(fd, Net.UNSPEC, name);
 497         } finally {
 498             end();
 499         }
 500     }
 501 
 502     private static class DefaultOptionsHolder {
 503         static final Set<SocketOption<?>> defaultOptions = defaultOptions();
 504 
 505         private static Set<SocketOption<?>> defaultOptions() {
 506             HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(5);
 507             set.add(StandardSocketOptions.SO_SNDBUF);
 508             set.add(StandardSocketOptions.SO_RCVBUF);
 509             set.add(StandardSocketOptions.SO_KEEPALIVE);
 510             set.add(StandardSocketOptions.SO_REUSEADDR);
 511             set.add(StandardSocketOptions.TCP_NODELAY);
 512             if (ExtendedOptionsImpl.flowSupported()) {
 513                 set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
 514             }
 515             return Collections.unmodifiableSet(set);
 516         }
 517     }
 518 
 519     @Override
 520     public final Set<SocketOption<?>> supportedOptions() {
 521         return DefaultOptionsHolder.defaultOptions;
 522     }
 523 
 524     @Override
 525     public final SocketAddress getRemoteAddress() throws IOException {
 526         if (!isOpen())




 486             throw new UnsupportedOperationException("'" + name + "' not supported");
 487 
 488         try {
 489             begin();
 490             if (name == StandardSocketOptions.SO_REUSEADDR &&
 491                     Net.useExclusiveBind())
 492             {
 493                 // SO_REUSEADDR emulated when using exclusive bind
 494                 return (T)Boolean.valueOf(isReuseAddress);
 495             }
 496             return (T) Net.getSocketOption(fd, Net.UNSPEC, name);
 497         } finally {
 498             end();
 499         }
 500     }
 501 
 502     private static class DefaultOptionsHolder {
 503         static final Set<SocketOption<?>> defaultOptions = defaultOptions();
 504 
 505         private static Set<SocketOption<?>> defaultOptions() {
 506             HashSet<SocketOption<?>> set = new HashSet<>(5);
 507             set.add(StandardSocketOptions.SO_SNDBUF);
 508             set.add(StandardSocketOptions.SO_RCVBUF);
 509             set.add(StandardSocketOptions.SO_KEEPALIVE);
 510             set.add(StandardSocketOptions.SO_REUSEADDR);
 511             set.add(StandardSocketOptions.TCP_NODELAY);
 512             if (ExtendedOptionsImpl.flowSupported()) {
 513                 set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
 514             }
 515             return Collections.unmodifiableSet(set);
 516         }
 517     }
 518 
 519     @Override
 520     public final Set<SocketOption<?>> supportedOptions() {
 521         return DefaultOptionsHolder.defaultOptions;
 522     }
 523 
 524     @Override
 525     public final SocketAddress getRemoteAddress() throws IOException {
 526         if (!isOpen())


< prev index next >