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:
Is there anything faster? This one hangs out depending on the time i've set.