Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Checking if remote device is still alive  RSS feed

 
Mike Skruf
Greenhorn
Posts: 3
Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the purpose of learning I have created a small multi-client multi-server java program.

The idea is that there are several servers, several clients and several client&servers connected in the same network.
Clients always connect to the servers with the lowest priority and send data to it (which server stores in a DB).
If a connection with the best available server is lost, the client connects to the next best server (until a better one advertises itself).

All works well, if I close the server program (ctrl+c). But if I unplug the network cable of the server, clients still continue to send the data to it as if it was alive.
So far I was using PrintWriter.checkError() but I guess it doesn't work in case of hardware failure.

Any other suggestions on how to check if server is receiving the data? (feel free to comment on the code aswell).






I found a possible solution:

InetAddress.getByName(host).isReachable(10000)

Is there anything faster? This one hangs out depending on the time i've set.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!