I'm writing tcp server and client applications. How can the server know when the connection to the client is not available, like when the client's computer suddenly crashed and no FIN flag sent?
When I try to write to the network stream it throws me an exception, I want to know how can I catch this exception without reading from / writing to the stream or another way to know if the stream is closed.
any help?
You can't, there's no way to check if the connection is close without catching an exception.
Attempting to write/read on the client will throw an exception which mean the connection is closed.