use of cn.hutool.socket.SocketRuntimeException in project hutool by looly.
the class AioClient method createChannel.
// ------------------------------------------------------------------------------------- Private method start
/**
* 初始化
*
* @param address 地址和端口
* @param poolSize 线程池大小
* @return this
*/
private static AsynchronousSocketChannel createChannel(InetSocketAddress address, int poolSize) {
AsynchronousSocketChannel channel;
try {
AsynchronousChannelGroup group = //
AsynchronousChannelGroup.withFixedThreadPool(// 默认线程池大小
poolSize, //
ThreadFactoryBuilder.create().setNamePrefix("Huool-socket-").build());
channel = AsynchronousSocketChannel.open(group);
} catch (IOException e) {
throw new IORuntimeException(e);
}
try {
channel.connect(address).get();
} catch (InterruptedException | ExecutionException e) {
IoUtil.close(channel);
throw new SocketRuntimeException(e);
}
return channel;
}
Aggregations