|
@@ -35,6 +35,7 @@ import java.net.InetSocketAddress;
|
|
|
import java.net.ServerSocket;
|
|
|
import java.net.Socket;
|
|
|
import java.net.SocketException;
|
|
|
+import java.net.StandardSocketOptions;
|
|
|
import java.net.UnknownHostException;
|
|
|
import java.nio.ByteBuffer;
|
|
|
import java.nio.channels.CancelledKeyException;
|
|
@@ -1105,12 +1106,16 @@ public abstract class Server {
|
|
|
private int backlogLength = conf.getInt(
|
|
|
CommonConfigurationKeysPublic.IPC_SERVER_LISTEN_QUEUE_SIZE_KEY,
|
|
|
CommonConfigurationKeysPublic.IPC_SERVER_LISTEN_QUEUE_SIZE_DEFAULT);
|
|
|
+ private boolean reuseAddr = conf.getBoolean(
|
|
|
+ CommonConfigurationKeysPublic.IPC_SERVER_REUSEADDR_KEY,
|
|
|
+ CommonConfigurationKeysPublic.IPC_SERVER_REUSEADDR_DEFAULT);
|
|
|
|
|
|
Listener(int port) throws IOException {
|
|
|
address = new InetSocketAddress(bindAddress, port);
|
|
|
// Create a new server socket and set to non blocking mode
|
|
|
acceptChannel = ServerSocketChannel.open();
|
|
|
acceptChannel.configureBlocking(false);
|
|
|
+ acceptChannel.setOption(StandardSocketOptions.SO_REUSEADDR, reuseAddr);
|
|
|
|
|
|
// Bind the server socket to the local host and port
|
|
|
bind(acceptChannel.socket(), address, backlogLength, conf, portRangeConfig);
|