--- a/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java Thu Mar 14 14:45:55 2013 +0100
+++ b/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java Thu Mar 14 13:46:15 2013 -0700
@@ -94,6 +94,12 @@
// Multicast support
private MembershipRegistry registry;
+ // set true when socket is bound and SO_REUSEADDRESS is emulated
+ private boolean reuseAddressEmulated;
+
+ // set true/false when socket is already bound and SO_REUSEADDR is emulated
+ private boolean isReuseAddress;
+
// -- End of fields protected by stateLock
@@ -222,6 +228,12 @@
}
return this;
}
+ if (name == StandardSocketOptions.SO_REUSEADDR &&
+ Net.useExclusiveBind() && localAddress != null)
+ {
+ reuseAddressEmulated = true;
+ this.isReuseAddress = (Boolean)value;
+ }
// remaining options don't need any special handling
Net.setSocketOption(fd, Net.UNSPEC, name, value);
@@ -280,6 +292,12 @@
}
}
+ if (name == StandardSocketOptions.SO_REUSEADDR &&
+ reuseAddressEmulated)
+ {
+ return (T)Boolean.valueOf(isReuseAddress);
+ }
+
// no special handling
return (T) Net.getSocketOption(fd, Net.UNSPEC, name);
}