< prev index next >
src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java
Print this page
*** 42,84 ****
static {
init();
}
protected <T> void setOption(SocketOption<T> name, T value) throws IOException {
! if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
super.setOption(name, value);
} else {
if (isClosed()) {
throw new SocketException("Socket closed");
}
checkSetOptionPermission(name);
checkValueType(value, SocketFlow.class);
setFlowOption(getFileDescriptor(), (SocketFlow)value);
}
}
@SuppressWarnings("unchecked")
protected <T> T getOption(SocketOption<T> name) throws IOException {
! if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
return super.getOption(name);
}
if (isClosed()) {
throw new SocketException("Socket closed");
}
checkGetOptionPermission(name);
SocketFlow flow = SocketFlow.create();
getFlowOption(getFileDescriptor(), flow);
return (T)flow;
}
protected Set<SocketOption<?>> supportedOptions() {
HashSet<SocketOption<?>> options = new HashSet<>(
super.supportedOptions());
if (flowSupported()) {
options.add(ExtendedSocketOptions.SO_FLOW_SLA);
}
return options;
}
protected void socketSetOption(int opt, Object val) throws SocketException {
try {
--- 42,97 ----
static {
init();
}
protected <T> void setOption(SocketOption<T> name, T value) throws IOException {
! if (!(name.equals(ExtendedSocketOptions.SO_FLOW_SLA)
! || (name.equals(ExtendedSocketOptions.SO_REUSEPORT)))) {
super.setOption(name, value);
} else {
if (isClosed()) {
throw new SocketException("Socket closed");
}
+ if (name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
checkSetOptionPermission(name);
checkValueType(value, SocketFlow.class);
setFlowOption(getFileDescriptor(), (SocketFlow)value);
+ } else {
+ checkValueType(value, Boolean.class);
+ setReusePortOption(getFileDescriptor(), ((Boolean)value).booleanValue());
+ }
}
}
@SuppressWarnings("unchecked")
protected <T> T getOption(SocketOption<T> name) throws IOException {
! if (!(name.equals(ExtendedSocketOptions.SO_FLOW_SLA)
! || (name.equals(ExtendedSocketOptions.SO_REUSEPORT)))) {
return super.getOption(name);
}
if (isClosed()) {
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 (flowSupported()) {
options.add(ExtendedSocketOptions.SO_FLOW_SLA);
}
+ if (reuseportSupported()) {
+ options.add(ExtendedSocketOptions.SO_REUSEPORT);
+ }
return options;
}
protected void socketSetOption(int opt, Object val) throws SocketException {
try {
< prev index next >