Socket client = 创建实例;
InputStream is = client.getInputStream();
DataInputStream dis = new DataInputStream(is);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int len = -1;
while ((len = dis.read(buf, 0, 1024)) != -1) {
baos.write(buf, 0, len);
}
在实际当中,代码会在while ((len = dis.read(buf, 0, 1024)) != -1)处卡死,导致程序一直等待,请问大家这是什么原因,如何解决?