How do you handle Socket Disconnecting in Java?

后端 未结 3 2025
暖寄归人
暖寄归人 2020-12-06 16:53

Hey all. I have a server written in java using the ServerSocket and Socket classes.

I want to be able to detect and handle disconnects, and then reconnect a new cl

3条回答
  •  醉酒成梦
    2020-12-06 17:24

    The only safe way to detect the other end has gone is to send heartbeats periodically and have the other end to timeout based on a lack of a heartbeat.

提交回复
热议问题