content: package echo;
  
  import io.netty.buffer.ByteBuf;
  import io.netty.buffer.Unpooled;
  import io.netty.channel.ChannelHandlerContext;
  import io.netty.channel.ChannelOutboundHandler;
  import io.netty.channel.ChannelOutboundHandlerAdapter;
  import io.netty.channel.SimpleChannelInboundHandler;
  import io.netty.util.CharsetUtil;
  
  public class EchoClientHandler extends SimpleChannelInboundHandler<ByteBuf> {
      
      // 读取到网络数据后进行业务处理，并关闭连接
      @Override
      protected void channelRead0(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf) throws Exception {
          System.out.println("client Accept " + byteBuf.toString(CharsetUtil.UTF_8));
          
          // 关闭连接
  //        channelHandlerContext.close();
      }
  
      @Override
      public void channelActive(ChannelHandlerContext ctx) throws Exception {
          ctx.writeAndFlush(Unpooled.copiedBuffer("Hello, Netty", CharsetUtil.UTF_8));
          
          // 
          ctx.alloc().buffer();
  //        super.channelActive(ctx);
      }
  }
  