Checking if a ClientSocket has disconnected in java hangs

后端 未结 3 1909
野的像风
野的像风 2020-12-10 08:59

This is a follow up to:

this question

Basically, I have a server loop that manages a connection to one solitary client. At one point in the loop, if a Clien

3条回答
  •  粉色の甜心
    2020-12-10 09:24

    You should add error checking in your disconnection detection. Sometimes an IOException may be thrown when the connection to the other end is lost.

    I am afraid that threading is unavoidable here. If you don't want to block the execution of your code, you need to create a separate thread.

提交回复
热议问题