TCP provides reliable, ordered, and error-checked delivery of a stream of octets (bytes) between applications running on hosts communicating via an IP network. Applications that do not require reliable data stream service may use the User Datagram Protocol (UDP), which provides a connectionless datagram service that emphasizes reduced latency over reliability. Ref: "wiki".
In general, if your server and clients work in:
- wired network instead of wireless network
- neither of them crashes
No need to implement a heartbeat.
While heartbeat/PING/keep-alive is absolute or only working way to check the connection. But how to implement a heartbeat is a good practice or best for you, depends on your use case, for example, how often the heartbeat is efficient for you? The possible reasons for the client lost connection.
More refences:
"Do I need to heartbeat to keep a TCP connection open?"
"Keep Alive TCP/IP connected sockets over the Internet - when? how? and how much?"
"TCP Dead link detection"