Android 使用java.net.socket 的接收问题

// 初始化socket
socket = new Socket(InetAddress.getByName(sip), sport);
InputStream sin = socket.getInputStream();
OutputStream ops = socket.getOutputStream();

// 发送
DataOutputStream dos=new DataOutputStream(ops);
dos.write(sendbyte);

// 接收
DataInputStream dis = new DataInputStream(sin); 
byte[] onerec = new byte[1024];
        int reclen = -1;
reclen = dis.read(onerec,0,1024);
问题:
连接和发送都正常,执行到接收的时候,dis.read()异常,总之只要开始操作sin肯定就异常退出了,
抓包显示服务器返回了数据包,但在inputStream变量的跟踪结果显示count=0。

原文地址:https://www.cnblogs.com/lhj588/p/3610414.html