Java编写服务器,遇java.net.SocketException: Software caused connection abort: recv failed错误,急
我在编写java集成服务器端时,出现了SocketException异常,错误如下:java.net.SocketException:Softwarecausedconn...
我在编写java集成服务器端时,出现了SocketException异常,错误如下:
java.net.SocketException: Software caused connection abort: recv failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.net.SocketInputStream.read(SocketInputStream.java:182)
at java.io.ObjectInputStream$PeekInputStream.peek(ObjectInputStream.java:2249)
at java.io.ObjectInputStream$BlockDataInputStream.peek(ObjectInputStream.java:2542)
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2552)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1297)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at nju.edu.server.XMLServer$ServerThread.run(XMLServer.java:86)
编译提示我的错误出现在下面代码的第五行:
try {
while(true){
ObjectInputStream in= new ObjectInputStream(socket.getInputStream());
ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
ServerOrder svod=(ServerOrder)in.readObject();
System.out.println(svod.ordertype);
Socket socketToC = new Socket("localhost",2400);
Socket socketToB = new Socket("localhost",2401);
按照异常提示,我的错误在于服务器在响应客户端socket时出现了问题。
现在在服务端读取客户端的ServerOrder(一个类)时,只在某些情况下可以读到,大多数情况都会报出这个异常,读不到任何类。
我不理解究竟问题出在哪儿,socket该关闭的都关闭了啊,而且也没有在进程结束前提前关闭的情况。
求大神帮助~~ 展开
java.net.SocketException: Software caused connection abort: recv failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.net.SocketInputStream.read(SocketInputStream.java:182)
at java.io.ObjectInputStream$PeekInputStream.peek(ObjectInputStream.java:2249)
at java.io.ObjectInputStream$BlockDataInputStream.peek(ObjectInputStream.java:2542)
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2552)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1297)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at nju.edu.server.XMLServer$ServerThread.run(XMLServer.java:86)
编译提示我的错误出现在下面代码的第五行:
try {
while(true){
ObjectInputStream in= new ObjectInputStream(socket.getInputStream());
ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
ServerOrder svod=(ServerOrder)in.readObject();
System.out.println(svod.ordertype);
Socket socketToC = new Socket("localhost",2400);
Socket socketToB = new Socket("localhost",2401);
按照异常提示,我的错误在于服务器在响应客户端socket时出现了问题。
现在在服务端读取客户端的ServerOrder(一个类)时,只在某些情况下可以读到,大多数情况都会报出这个异常,读不到任何类。
我不理解究竟问题出在哪儿,socket该关闭的都关闭了啊,而且也没有在进程结束前提前关闭的情况。
求大神帮助~~ 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询