java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:210) at java.net.SocketInputStream.read(SocketInputStream.java:141) at java.net.SocketInputStream.read(SocketInputStream.java:224) at java.io.ObjectInputStream$PeekInputStream.peek(ObjectInputStream.java:2598) at java.io.ObjectInputStream$BlockDataInputStream.peek(ObjectInputStream.java:2905) at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2915) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1502) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:422) at chat.Server.lambda$0(Server.java:29) at java.lang.Thread.run(Thread.java:748)
当客户端socket从服务器socket上断开连接后,服务器socket会抛出异常,如何解决这个异常?
出现异常的频率,是怎么样的
客户端在断开的时候,给服务器端发送一个断开的消息,然后再断开,服务器端收到这个断开的消息后,也将socket断开,这样就不会有异常了。