[#2605] Use SO_REUSEADDR on EpollServerSocketChannel to match defaults of java.nio.ServerSocketChannel impl

Motivation:

When using openjdk and oracle jdk's nio (while using the nio transport) the ServerSocketChannel uses SO_REUSEADDR by default. Our native transport should do the same to make it easier to switch between the different implementations and get the expected result.

Modification:

Change EpollServerSocketChannelConfig to set SO_REUSEADDR on the created socket.

Result:

SO_REUSEADDR is used by default on servers.
This commit is contained in:
Norman Maurer 2014-06-26 11:53:23 +02:00
parent d2e385acc2
commit b0e5c9be00

View File

@ -38,6 +38,11 @@ public final class EpollServerSocketChannelConfig extends DefaultChannelConfig
EpollServerSocketChannelConfig(EpollServerSocketChannel channel) {
super(channel);
this.channel = channel;
// Use SO_REUSEADDR by default as java.nio does the same.
//
// See https://github.com/netty/netty/issues/2605
setReuseAddress(true);
}
@Override