1,粘包/拆包问题
2,粘包/拆包的解决策略
3,String解码器
socketChannel.pipeline().addLast(new StringDecoder());
4,换行符转码器(特殊的分隔符)
request = ("QUERY TIME ORDER" + System.getProperty("line.separator")).getBytes();
socketChannel.pipeline().addLast(new LineBasedFrameDecoder(222));
5,分隔符转码器
socketChannel.pipeline().addLast(new DelimiterBasedFrameDecoder(1024,delimiter));
1024-读取buffer的最大长度,如果超过该长度还没读取到分隔符则抛出异常
delimiter-分隔符
6,定长转码器
socketChannel.pipeline().addLast(new FixedLengthFrameDecoder(20));