diff -r be617b8c4427 -r fa6bd0992104 jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java --- a/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java Thu Mar 14 14:45:55 2013 +0100 +++ b/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java Thu Mar 14 13:46:15 2013 -0700 @@ -70,6 +70,9 @@ // -- The following fields are protected by stateLock + // set true when exclusive binding is on and SO_REUSEADDR is emulated + private boolean isReuseAddress; + // State, increases monotonically private static final int ST_UNINITIALIZED = -1; private static final int ST_UNCONNECTED = 0; @@ -174,6 +177,12 @@ if (!Net.isIPv6Available()) Net.setSocketOption(fd, StandardProtocolFamily.INET, name, value); return this; + } else if (name == StandardSocketOptions.SO_REUSEADDR && + Net.useExclusiveBind()) + { + // SO_REUSEADDR emulated when using exclusive bind + isReuseAddress = (Boolean)value; + return this; } // no options that require special handling @@ -196,6 +205,13 @@ if (!isOpen()) throw new ClosedChannelException(); + if (name == StandardSocketOptions.SO_REUSEADDR && + Net.useExclusiveBind()) + { + // SO_REUSEADDR emulated when using exclusive bind + return (T)Boolean.valueOf(isReuseAddress); + } + // special handling for IP_TOS: always return 0 when IPv6 if (name == StandardSocketOptions.IP_TOS) { return (Net.isIPv6Available()) ? (T) Integer.valueOf(0) :