Listen to disconnect tcp clients in google chrome app
The documentation for chrome.sockets.tcpServer and chrome.sockets.tcp doesn't mention anywhere how to listen for client disconnects. How can i do this?
I found out what you got resultCode == -15
in the function callback chrome.sockets.tcp.send
if the client was disconnected. But I really want to be notified if someone disconnects instead of just using a proactive method to check for it.
source to share
I understand that disconnecting sockets is not something the underlying OS can detect. There is no way at the socket level to tell the difference between a client who left and a client who might just take the time to send the next packet. Perhaps someone with deeper knowledge of TCP / IP will fix me, but this is always the answer I have seen.
You can send a disconnect message to the clients at the application level, otherwise a periodic heartbeat may occur, without which the server will shut down with the client. More details here: Is TCP Keepalive the only mechanism to detect a broken link?
source to share