< prev index next >
src/java.base/unix/classes/java/net/PlainSocketImpl.java
Print this page
@@ -56,43 +56,55 @@
PlainSocketImpl(FileDescriptor fd) {
this.fd = fd;
}
protected <T> void setOption(SocketOption<T> name, T value) throws IOException {
- if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
+ if (!(name.equals(ExtendedSocketOptions.SO_FLOW_SLA)
+ || (name.equals(ExtendedSocketOptions.SO_REUSEPORT)))) {
super.setOption(name, value);
} else {
if (isClosedOrPending()) {
throw new SocketException("Socket closed");
}
+ if (name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
checkSetOptionPermission(name);
checkValueType(value, SocketFlow.class);
setFlowOption(getFileDescriptor(), (SocketFlow)value);
+ } else {
+ setReusePortOption(getFileDescriptor(), ((Boolean)value).booleanValue());
+ }
}
}
@SuppressWarnings("unchecked")
protected <T> T getOption(SocketOption<T> name) throws IOException {
- if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
+ if (!(name.equals(ExtendedSocketOptions.SO_FLOW_SLA)
+ || (name.equals(ExtendedSocketOptions.SO_REUSEPORT)))) {
return super.getOption(name);
}
if (isClosedOrPending()) {
throw new SocketException("Socket closed");
}
+ if (name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
checkGetOptionPermission(name);
SocketFlow flow = SocketFlow.create();
getFlowOption(getFileDescriptor(), flow);
return (T)flow;
}
+ return (T)getReusePortOption(getFileDescriptor());
+ }
protected Set<SocketOption<?>> supportedOptions() {
HashSet<SocketOption<?>> options = new HashSet<>(
super.supportedOptions());
if (getSocket() != null && flowSupported()) {
options.add(ExtendedSocketOptions.SO_FLOW_SLA);
}
+ if (getSocket() != null && reuseportSupported()) {
+ options.add(ExtendedSocketOptions.SO_REUSEPORT);
+ }
return options;
}
protected void socketSetOption(int opt, boolean b, Object val) throws SocketException {
try {
< prev index next >