|  |  | 
 |  |  |  | 
 |  |  | import io.netty.bootstrap.Bootstrap; | 
 |  |  | import io.netty.channel.ChannelFuture; | 
 |  |  | import io.netty.channel.ChannelFutureListener; | 
 |  |  | import io.netty.channel.ChannelInitializer; | 
 |  |  | import io.netty.channel.nio.NioEventLoopGroup; | 
 |  |  | import io.netty.channel.socket.SocketChannel; | 
 |  |  | 
 |  |  |                         } | 
 |  |  |                     }); | 
 |  |  |             ChannelFuture future = bootstrap.connect(host, port).sync(); | 
 |  |  |             // 添加连接成功的监听器 | 
 |  |  |             future.addListener((ChannelFutureListener) future1 -> { | 
 |  |  |                 if (future1.isSuccess()) { | 
 |  |  |                     log.info("tcp连接成功"+host+":"+port); | 
 |  |  |                 } else { | 
 |  |  |                     log.info("tcp连接失败"+host+":"+port); | 
 |  |  |                 } | 
 |  |  |             }); | 
 |  |  |             future.channel().closeFuture().sync(); | 
 |  |  |  | 
 |  |  |         } catch (Exception ex) { |