This commit is contained in:
@@ -134,7 +134,7 @@ public abstract class AsyncConnection implements AsynchronousByteChannel, AutoCl
|
|||||||
* @throws java.io.IOException 异常
|
* @throws java.io.IOException 异常
|
||||||
*/
|
*/
|
||||||
public static CompletableFuture<AsyncConnection> createTCP(final AsynchronousChannelGroup group, final SocketAddress address,
|
public static CompletableFuture<AsyncConnection> createTCP(final AsynchronousChannelGroup group, final SocketAddress address,
|
||||||
final int readTimeoutSecond, final int writeTimeoutSecond) throws IOException {
|
final int readTimeoutSecond, final int writeTimeoutSecond) {
|
||||||
return createTCP(group, address, false, readTimeoutSecond, writeTimeoutSecond);
|
return createTCP(group, address, false, readTimeoutSecond, writeTimeoutSecond);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,11 +148,11 @@ public abstract class AsyncConnection implements AsynchronousByteChannel, AutoCl
|
|||||||
* @param writeTimeoutSecond 写入超时秒数
|
* @param writeTimeoutSecond 写入超时秒数
|
||||||
*
|
*
|
||||||
* @return 连接CompletableFuture
|
* @return 连接CompletableFuture
|
||||||
* @throws java.io.IOException 异常
|
|
||||||
*/
|
*/
|
||||||
public static CompletableFuture<AsyncConnection> createTCP(final AsynchronousChannelGroup group, final SocketAddress address,
|
public static CompletableFuture<AsyncConnection> createTCP(final AsynchronousChannelGroup group, final SocketAddress address,
|
||||||
final boolean noDelay, final int readTimeoutSecond, final int writeTimeoutSecond) throws IOException {
|
final boolean noDelay, final int readTimeoutSecond, final int writeTimeoutSecond) {
|
||||||
final CompletableFuture future = new CompletableFuture();
|
final CompletableFuture future = new CompletableFuture();
|
||||||
|
try {
|
||||||
final AsynchronousSocketChannel channel = AsynchronousSocketChannel.open(group);
|
final AsynchronousSocketChannel channel = AsynchronousSocketChannel.open(group);
|
||||||
channel.connect(address, null, new CompletionHandler<Void, Void>() {
|
channel.connect(address, null, new CompletionHandler<Void, Void>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -171,6 +171,9 @@ public abstract class AsyncConnection implements AsynchronousByteChannel, AutoCl
|
|||||||
future.completeExceptionally(exc);
|
future.completeExceptionally(exc);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} catch (IOException e) {
|
||||||
|
future.completeExceptionally(e);
|
||||||
|
}
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user