Generally speaking, you won't know if a client is still available or not. They may explicitly disconnect, but they may never do so, either due to network issues, poorly coded client software, or maliciousness. Reading for zero bytes will tell you when a client disconnects, but that's not always sufficient for appropriate client management.
Often network protocols will include the concept of a keepalive or a heartbeat, so that a server can know when clients are no longer responsive, whether due to an explicit disconnection, lost packets, network partitions, or other reasons.
For example: The protocol might require that clients to send a specific message, like
HEARTBEAT\n\n after every 10 seconds of inactivity, and then if you haven't received a keepalive or other message from a client for 30 seconds, assume they are no longer available, and disconnect from the server side.
The protocol may also specify that clients and servers send a specific message before disconnecting, but this only helps with well-behaved clients.
See, for example: https://en.wikipedia.org/wiki/HTTP_persistent_connection for how connections are managed in HTTP.