当前位置:编程学习 > JAVA >>

Connection reset 异常问题 求帮忙!!!

java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.io.ObjectInputStream$PeekInputStream.read(Unknown Source)
at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
at com.mytest.server.pojo.InputThread.<init>(InputThread.java:44)
at com.mytest.server.Client.run(Client.java:30)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)



代码如下:

public InputThread(OutputThread out, Socket socket, OutputThreadMap map) {
super();
this.out = out;
this.socket = socket;
this.map = map;
try {
// DataInputStream obj = new  DataInputStream(socket.getInputStream());
ois = new ObjectInputStream(this.socket.getInputStream());
} catch (IOException e) {
System.out.println(ois + "---------------");
e.printStackTrace();
}
}


报错行 在 new ObjectInputStream(this.socket.getInputStream())
this.socket.getInputStream()这个对象已经取到了 但是在new的时候就报错了.
方法如果换为注释掉的 new DataInputStream 就不会报错.

--------------------编程问答-------------------- 你传输的那个对象序列化了么? --------------------编程问答-------------------- 已经实现序列化了
补充:Java ,  Java相关
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,