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