本文共 469 字,大约阅读时间需要 1 分钟。
// 初始化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。 转载地址:http://hhodm.baihongyu.com/