network: ping pong keepalive for tcp connections

To make the tcp connections keepalive and better handle the timeout
of connections

con_timeout indicate the connection timeout and it is configurable

Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
This commit is contained in:
Chen Minqiang 2022-07-21 06:03:58 +08:00 committed by Nick Hainke
parent eba03547a5
commit 47e98efed6
8 changed files with 136 additions and 30 deletions

View file

@ -109,7 +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.
time_t con_timeout; // Check for connection timeouts.
};
struct local_config_s {

View file

@ -5,7 +5,7 @@
#include <netinet/in.h>
#define ARRAY_NETWORK_LEN 50
#define CHECK_CLIENT_TIMEOUT 5
#define CHECK_TIMEOUT 10
struct network_con_s {
struct list_head list;
@ -14,6 +14,7 @@ struct network_con_s {
struct ustream_fd stream;
struct sockaddr_in sock_addr;
int connected;
time_t time_alive;
};
/**
@ -38,9 +39,14 @@ int run_server(int port);
void send_tcp(char *msg);
/**
* Check sockets for client timeouts.
* Send ping to clients
*/
void check_client_timeout(int timeout);
void server_to_clients_ping(void);
/**
* Check sockets timeouts.
*/
void check_timeout(int timeout);
/**
* Debug message.