165 throw new UnsupportedOperationException("'" + name + "' not supported");
166
167 synchronized (stateLock) {
168 if (!isOpen())
169 throw new ClosedChannelException();
170 if (name == StandardSocketOptions.SO_REUSEADDR &&
171 Net.useExclusiveBind())
172 {
173 // SO_REUSEADDR emulated when using exclusive bind
174 return (T)Boolean.valueOf(isReuseAddress);
175 }
176 // no options that require special handling
177 return (T) Net.getSocketOption(fd, Net.UNSPEC, name);
178 }
179 }
180
181 private static class DefaultOptionsHolder {
182 static final Set<SocketOption<?>> defaultOptions = defaultOptions();
183
184 private static Set<SocketOption<?>> defaultOptions() {
185 HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(2);
186 set.add(StandardSocketOptions.SO_RCVBUF);
187 set.add(StandardSocketOptions.SO_REUSEADDR);
188 set.add(StandardSocketOptions.IP_TOS);
189 return Collections.unmodifiableSet(set);
190 }
191 }
192
193 @Override
194 public final Set<SocketOption<?>> supportedOptions() {
195 return DefaultOptionsHolder.defaultOptions;
196 }
197
198 public boolean isBound() {
199 synchronized (stateLock) {
200 return localAddress != null;
201 }
202 }
203
204 public InetSocketAddress localAddress() {
205 synchronized (stateLock) {
|
165 throw new UnsupportedOperationException("'" + name + "' not supported");
166
167 synchronized (stateLock) {
168 if (!isOpen())
169 throw new ClosedChannelException();
170 if (name == StandardSocketOptions.SO_REUSEADDR &&
171 Net.useExclusiveBind())
172 {
173 // SO_REUSEADDR emulated when using exclusive bind
174 return (T)Boolean.valueOf(isReuseAddress);
175 }
176 // no options that require special handling
177 return (T) Net.getSocketOption(fd, Net.UNSPEC, name);
178 }
179 }
180
181 private static class DefaultOptionsHolder {
182 static final Set<SocketOption<?>> defaultOptions = defaultOptions();
183
184 private static Set<SocketOption<?>> defaultOptions() {
185 HashSet<SocketOption<?>> set = new HashSet<>(2);
186 set.add(StandardSocketOptions.SO_RCVBUF);
187 set.add(StandardSocketOptions.SO_REUSEADDR);
188 set.add(StandardSocketOptions.IP_TOS);
189 return Collections.unmodifiableSet(set);
190 }
191 }
192
193 @Override
194 public final Set<SocketOption<?>> supportedOptions() {
195 return DefaultOptionsHolder.defaultOptions;
196 }
197
198 public boolean isBound() {
199 synchronized (stateLock) {
200 return localAddress != null;
201 }
202 }
203
204 public InetSocketAddress localAddress() {
205 synchronized (stateLock) {
|