}
public int start(String ip,int port) {
System.setProperty(“java.net.preferIPv4Stack”, “true”);
System.setProperty(“java.net.preferIPv6Addresses”, “false”);
bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool()));
bootstrap.setPipelineFactory(new CmdPipelineFactory());
bootstrap.setOption(“tcpNoDelay”, true);
bootstrap.setOption(“keepAlive”, true);
channelFuture = bootstrap.connect(new InetSocketAddress(ip, port));
channelFuture.awaitUninterruptibly();
channel = channelFuture.awaitUninterruptibly().getChannel();
return 1;
}
public void stop() {
channelFuture.awaitUninterruptibly();
if (!channelFuture.isSuccess()) {
channelFuture.getCause().printStackTrace();
}
channelFuture.getChannel().getCloseFuture().awaitUnin