程序代码如下:
public byte[][] sendCmdData(Socket socket, String data[])
throws IOException 
{ 1。OutputStream out = socket.getOutputStream();
  2。headLength = data[i].getBytes().length;
  3。sendData = (((headLength / 255) & 0xff)+ ((headLength % 255) & 0xff )+ data[i]).getBytes();
 4。out.write(sendData);
 5。out.flush();
 6。InputStream in = socket.getInputStream();
 7。in.read(temp);
.....
}
注:在语句6之前都执行无误,且sendData为已经组好的包,调试时也有响应的数据。
    语句1。中的socket是该函数的输入参数,这个值为另一个建立socket的方法的返回值,方法定义如下:
public Socket connectHsm(String connectIP, long port)
throws SecurityException, IOException {
Socket conSock = null;
try {
if (connectIP.equals(connectIP1)) {
conSock = new Socket(InetAddress.getByName(connectIP1), 8);
} else {
conSock = new Socket(InetAddress.getByName(connectIP2), 5555);
}
conSock.setSoTimeout(8000);
return conSock; } catch (SecurityException e) {
System.out.println("SecurityException when connecting Server!");
throw e;
} catch (IOException e) {
System.out.println("IOException when connect to Server!");
}
System.out.println("successfully connected....");
return null;
}问题:在执行方法sendCmdData的语句7时,抛出异常,提示java.net.SocketException: Connection reset。
请问:为什么socket被重置了啊?另在调用上述两个方法的函数中使用了socket.close().
谢谢!