解析: 首先是读取字节: /** * 读取输入流中指定字节的长度 * <p/> * 输入流 * * @param length 指定长度 * @return 指定长度的字节数组 */ public static byte[] readBytesFromTo(byte[] buffer, int from, int length) { byte[] sub = new byte[length]; int cur = 0; for (int i = from; i < length + fr…
逻辑就是在处理handler前加入一个处理符,然后 channelReadComplete这个事件进行处理.同时注意客服端的配置: public void connect(String addr, int port, final String xml, final String key,final boolean flag) throws Exception { EventLoopGroup group = new NioEventLoopGroup(); try { Bootstrap b =…
一. Server public class TimeServer_argu { public void bind(int port) throws InterruptedException { EventLoopGroup bossGroup = new NioEventLoopGroup(); // 默认开启cpu个数*2个线程 EventLoopGroup workerGroup = new NioEventLoopGroup(); try { ServerBootstrap server…