This commit is contained in:
@@ -188,14 +188,14 @@ public abstract class AsyncConnection implements AsynchronousByteChannel, AutoCl
|
||||
final CompletableFuture<AsyncConnection> future = new CompletableFuture<>();
|
||||
try {
|
||||
final AsynchronousSocketChannel channel = AsynchronousSocketChannel.open(group);
|
||||
try {
|
||||
if (noDelay) channel.setOption(StandardSocketOptions.TCP_NODELAY, true);
|
||||
if (supportTcpKeepAlive()) channel.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
channel.connect(address, null, new CompletionHandler<Void, Void>() {
|
||||
@Override
|
||||
public void completed(Void result, Void attachment) {
|
||||
try {
|
||||
if (noDelay) channel.setOption(StandardSocketOptions.TCP_NODELAY, true);
|
||||
if (supportTcpKeepAlive()) channel.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
future.complete(create(channel, sslContext, address, readTimeoutSeconds, writeTimeoutSeconds));
|
||||
}
|
||||
|
||||
|
||||
@@ -206,6 +206,11 @@ public abstract class ProtocolServer {
|
||||
public void open() throws IOException {
|
||||
group = AsynchronousChannelGroup.withCachedThreadPool(context.executor, 1);
|
||||
this.serverChannel = AsynchronousServerSocketChannel.open(group);
|
||||
try {
|
||||
if (supportTcpNoDelay()) this.serverChannel.setOption(StandardSocketOptions.TCP_NODELAY, true);
|
||||
if (supportTcpKeepAlive()) this.serverChannel.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -240,11 +245,6 @@ public abstract class ProtocolServer {
|
||||
}
|
||||
createCounter.incrementAndGet();
|
||||
livingCounter.incrementAndGet();
|
||||
try {
|
||||
if (supportTcpNoDelay()) channel.setOption(StandardSocketOptions.TCP_NODELAY, true);
|
||||
if (supportTcpKeepAlive()) channel.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
AsyncConnection conn = AsyncConnection.create(channel, null, context);
|
||||
conn.livingCounter = livingCounter;
|
||||
conn.closedCounter = closedCounter;
|
||||
|
||||
Reference in New Issue
Block a user