0

I've a Socket connected to another device on my LAN. How can i detect the disconnection When i unplug the device from the AC. The thread is blocked on:

BufferedReader b=//
b.readLine();
Raidri
  • 17,258
  • 9
  • 62
  • 65
natio
  • 41
  • 1
  • 1
  • 4

1 Answers1

1

If you're going to use such logic, then set a timeout on the socket (i.e. setSoTimeout(TIMEOUT_IN_MILLISECONDS)). This will interrupt the blocking I/O operation.

mre
  • 43,520
  • 33
  • 120
  • 170