mfavant / tubekit

NEW PROJECT https://github.com/crust-hub/avant
MIT License
0 stars 0 forks source link

feat: Heartbeat detection #22

Closed gaowanlu closed 3 months ago

gaowanlu commented 5 months ago

Currently, after attaching, the client shuts down or the process crashes, causing the server to be unable to know that the client socket has been closed. It is necessary to design a heartbeat timeout mechanism to actively close the failed socket connection.

gaowanlu commented 5 months ago

on_tick , to check every socket object 's lastest 'detach time'. Dispatch a task for a timeout so that it can shut itself down in the worker thread.

gaowanlu commented 5 months ago

Using C++ Priority Queue Processing.

gaowanlu commented 5 months ago

std::deque + std::priority_queue + socketobject ptr

gaowanlu commented 5 months ago

In fact, to detect whether the peer is disconnected, active detection is required. One is that the connection layer periodically attempts to read, and the other is that the application layer peer sends packets regularly. When the timeout occurs, the server disconnects the connection.