network: add timeout for client connections

Somtimes client connetions will not close therfore add a timeout. Add a
new timer that checks every 5s if we did not receive anything from a
client for (default) 60s. Can be configured via client_timeout.

Code is based on the work of ptpt52.

Signed-off-by: Nick Hainke <vincent@systemli.org>
This commit is contained in:
Nick Hainke 2022-07-20 13:30:00 +02:00
parent e596ff1317
commit eba03547a5
8 changed files with 50 additions and 0 deletions

View file

@ -109,6 +109,7 @@ struct time_config_s {
time_t update_tcp_con; // Refresh network connections
time_t update_chan_util; // Refresh per radio / SSID channel util info
time_t update_beacon_reports; // Request BEACON from capable clients
time_t client_timeout; // Check for client timeouts.
};
struct local_config_s {

View file

@ -5,6 +5,7 @@
#include <netinet/in.h>
#define ARRAY_NETWORK_LEN 50
#define CHECK_CLIENT_TIMEOUT 5
struct network_con_s {
struct list_head list;
@ -36,6 +37,11 @@ int run_server(int port);
*/
void send_tcp(char *msg);
/**
* Check sockets for client timeouts.
*/
void check_client_timeout(int timeout);
/**
* Debug message.
*/