davydnorris wrote:This is the way TCP/IP works unfortunately - the protocol itself is responsible for implementing a way to detect broken connections, there's nothing at the TCP level that does it.
What I have done is to use MQTT protocol, which has a heartbeat that you can set - if the client (or server) misses the heartbeat for too long then the connection is declared dead and can be reported on as part of the protocol. In fact you can personalise the reporting by using MQTT's Last Will and Testament (LWT), which lets a client specify a topic and a message to publish on behalf of the client if the connection is deemed dead.
Thank you!
As of now, the server I'm using having a custom TCP based protocol. If no workarounds available, then I'm planning to replace the server with any available MQTT broker. This could save time.