socket如何接收服务端发送的数据

2025-04-26 14:25:52
推荐回答(1个)
回答1:

你好,我认为是read每次读取一个字节的引起的
试着改写一下:
public static byte[] read(DataInput in) throws IOException {
int len = in.readInt();
byte[] bytes = new byte[len];
in.readFully(bytes);
return bytes;
}

换用这个改写的方法可能会解决你的问题!!!