一个奇怪的现象:private ByteBuffer w_buff = ByteBuffer.allocate(2048);w_buff.clear();
byte[] temp = new byte[1024];
w_buff = ByteBuffer.wrap(temp);//这句和下句的差别好大!!
w_buff.put(temp);int w = sc.write(w_buff);
System.out.println("发送加法请求: " + w);
有兴趣的可以试试,好Wrap多少字节就Write多少字节。而put X字节,就write2048-X个谁给解释下