// 启动监听和链接
ChannelFuture channelFuture = bootstrap.connect(ip, port).sync();
if (channelFuture.isSuccess()) {
System.out.println("链接server 成功");
}
channelFuture.channel().closeFuture().sync();
channel.writeAndFlush(request).addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture f) throws Exception {
if (f.isSuccess()) {
responseFuture.setSendRequestOK(true);
return;
} else {
responseFuture.setSendRequestOK(false);
}
responseTable.remove(opaque);
responseFuture.setCause(f.cause());
responseFuture.putResponse(null);
log.warn("send a request command to channel <" + addr + "> failed.");
}
});
这里是要主动发送对应的数据的