// 初始化socket
socket = new Socket(InetAddress.getByName(sip), sport);
InputStream sin = socket.getInputStream();
OutputStream ops = socket.getOutputStream();
// 發(fā)送
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);
問題:
連接和發(fā)送都正常,執(zhí)行到接收的時候,dis.read()異常,總之只要開始操作sin肯定就異常退出了,
抓包顯示服務(wù)器返回了數(shù)據(jù)包,但在inputStream變量的跟蹤結(jié)果顯示count=0。