I swear I had this before but now i cant get it back.

If I have a server client setup, how can I detect from client if the server no longer exists, example the server exists (could be because the server did not respond and we ended task) or perhaps there was a power failure and the PC switched off - in this sort of situation the client should know if there still is a connection to listen to..... how can I make it do this on the client side when listening to communication?

I swear I had it before but after modifying code, and changing it back, i cannot seem to reproduce this behaviour

thanks!