|
ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
|
💓 Ping/pong keepalive and timeout detection More...
Files | |
| file | keepalive.c |
| 💓 Client keepalive: periodic ping/pong exchange for reliable connection failure detection | |
| file | keepalive.h |
| ascii-chat Client Connection Keepalive Management Interface | |
Functions | |
| __attribute__ ((unused)) | |
| Ping/keepalive thread handle. | |
| int | keepalive_start_thread () |
| Start keepalive/ping thread. | |
| void | keepalive_stop_thread () |
| Stop keepalive/ping thread. | |
| bool | keepalive_thread_exited () |
| Check if keepalive thread has exited. | |
💓 Ping/pong keepalive and timeout detection
The keepalive subsystem manages connection liveness by sending periodic ping packets and detecting pong timeouts to identify dead connections.
Implementation: src/client/keepalive.c, src/client/keepalive.h
Timing Parameters:
| __attribute__ | ( | (unused) | ) |
#include <keepalive.c>
Ping/keepalive thread handle.
Thread handle for the background thread that sends periodic PING packets to detect connection health. Created during connection establishment, joined during shutdown. Ping interval in seconds (must be less than server timeout) Sleep interval for ping timing loop (1 second) Main ping/keepalive thread function
Implements periodic ping transmission to maintain connection health. Monitors connection state and coordinates with global shutdown logic.
Ping Loop Operation:
Error Handling:
| arg | Unused thread argument |
Definition at line 89 of file keepalive.c.
References asciichat_errno_cleanup(), crypto_client_initiate_rekey(), crypto_client_should_rekey(), fps_frame(), fps_init_with_interval(), log_debug, log_error, PING_INTERVAL_SECONDS, PING_SLEEP_INTERVAL_SECONDS, platform_sleep_ms(), platform_sleep_usec(), server_connection_is_active(), server_connection_is_lost(), server_connection_lost(), should_exit(), and threaded_send_ping_packet().
| int keepalive_start_thread | ( | ) |
#include <keepalive.c>
Start keepalive/ping thread.
Start keepalive/ping thread
Creates and starts the ping thread for connection keepalive. Must be called after successful server connection establishment.
Definition at line 234 of file keepalive.c.
References ASCIICHAT_OK, g_client_worker_pool, LOG_ERRNO_IF_SET, log_error, log_warn, and thread_pool_spawn().
Referenced by protocol_start_connection().
| void keepalive_stop_thread | ( | ) |
#include <keepalive.c>
Stop keepalive/ping thread.
Stop keepalive/ping thread
Gracefully stops the ping thread and cleans up resources. Safe to call multiple times.
Definition at line 260 of file keepalive.c.
References log_info, log_warn, and platform_sleep_usec().
Referenced by protocol_stop_connection().
| bool keepalive_thread_exited | ( | ) |
#include <keepalive.c>
Check if keepalive thread has exited.
Check if keepalive thread has exited
Definition at line 292 of file keepalive.c.