|
ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
|
Go to the source code of this file.
Macros | |
| #define | MAX_RECONNECT_DELAY (5LL * NS_PER_SEC_INT) |
Functions | |
| tcp_client_t * | tcp_client_create (void) |
| Create and initialize TCP client. | |
| void | tcp_client_destroy (tcp_client_t **client_ptr) |
| Destroy TCP client and free resources. | |
| bool | tcp_client_is_active (const tcp_client_t *client) |
| Check if connection is currently active. | |
| bool | tcp_client_is_lost (const tcp_client_t *client) |
| Check if connection was lost. | |
| socket_t | tcp_client_get_socket (const tcp_client_t *client) |
| Get current socket descriptor. | |
| uint32_t | tcp_client_get_id (const tcp_client_t *client) |
| Get client ID assigned by server. | |
| void | tcp_client_signal_lost (tcp_client_t *client) |
| Signal that connection was lost (triggers reconnection) | |
| void | tcp_client_close (tcp_client_t *client) |
| Close connection gracefully. | |
| void | tcp_client_shutdown (tcp_client_t *client) |
| Shutdown connection forcefully (for signal handlers) | |
| int | tcp_client_send_packet (tcp_client_t *client, packet_type_t type, const void *data, size_t len) |
| Send packet with thread-safe mutex protection. | |
| int | tcp_client_send_ping (tcp_client_t *client) |
| Send ping packet. | |
| int | tcp_client_send_pong (tcp_client_t *client) |
| Send pong packet. | |
| int | tcp_client_connect (tcp_client_t *client, const char *address, int port, int reconnect_attempt, bool first_connection, bool has_ever_connected) |
| Establish TCP connection to server. | |
| #define MAX_RECONNECT_DELAY (5LL * NS_PER_SEC_INT) |
Maximum delay between reconnection attempts (nanoseconds)
Definition at line 56 of file lib/network/tcp/client.c.
| void tcp_client_close | ( | tcp_client_t * | client | ) |
Close connection gracefully.
Definition at line 202 of file lib/network/tcp/client.c.
| int tcp_client_connect | ( | tcp_client_t * | client, |
| const char * | address, | ||
| int | port, | ||
| int | reconnect_attempt, | ||
| bool | first_connection, | ||
| bool | has_ever_connected | ||
| ) |
Establish TCP connection to server.
Performs full connection lifecycle:
| client | TCP client instance |
| address | Server hostname or IP address |
| port | Server port number |
| reconnect_attempt | Current reconnection attempt (0 for first, 1+ for retries) |
| first_connection | True if this is the very first connection since program start |
| has_ever_connected | True if client has successfully connected at least once |
Definition at line 311 of file lib/network/tcp/client.c.
References connect_with_timeout(), format_ip_address(), is_localhost_ipv4(), is_localhost_ipv6(), network_error_string(), and socket_configure_buffers().
Referenced by connection_attempt_tcp().
| tcp_client_t * tcp_client_create | ( | void | ) |
Create and initialize TCP client.
Allocates tcp_client_t and initializes all fields to safe defaults.
Definition at line 95 of file lib/network/tcp/client.c.
References mutex_init().
Referenced by connection_attempt_tcp(), and session_client_like_run().
| void tcp_client_destroy | ( | tcp_client_t ** | client_ptr | ) |
Destroy TCP client and free resources.
Must be called AFTER all threads have been joined.
Definition at line 127 of file lib/network/tcp/client.c.
References mutex_destroy().
Referenced by connection_attempt_tcp(), connection_context_cleanup(), and session_client_like_run().
| uint32_t tcp_client_get_id | ( | const tcp_client_t * | client | ) |
Get client ID assigned by server.
Definition at line 177 of file lib/network/tcp/client.c.
| socket_t tcp_client_get_socket | ( | const tcp_client_t * | client | ) |
Get current socket descriptor.
Definition at line 170 of file lib/network/tcp/client.c.
Referenced by connection_attempt_tcp().
| bool tcp_client_is_active | ( | const tcp_client_t * | client | ) |
Check if connection is currently active.
Definition at line 152 of file lib/network/tcp/client.c.
| bool tcp_client_is_lost | ( | const tcp_client_t * | client | ) |
Check if connection was lost.
Definition at line 161 of file lib/network/tcp/client.c.
| int tcp_client_send_packet | ( | tcp_client_t * | client, |
| packet_type_t | type, | ||
| const void * | data, | ||
| size_t | len | ||
| ) |
Send packet with thread-safe mutex protection.
All packet transmission goes through this function to ensure packets aren't interleaved on the wire.
Definition at line 246 of file lib/network/tcp/client.c.
References send_packet().
Referenced by tcp_client_send_ping(), and tcp_client_send_pong().
| int tcp_client_send_ping | ( | tcp_client_t * | client | ) |
Send ping packet.
Definition at line 274 of file lib/network/tcp/client.c.
References tcp_client_send_packet().
| int tcp_client_send_pong | ( | tcp_client_t * | client | ) |
Send pong packet.
Definition at line 283 of file lib/network/tcp/client.c.
References tcp_client_send_packet().
| void tcp_client_shutdown | ( | tcp_client_t * | client | ) |
Shutdown connection forcefully (for signal handlers)
Definition at line 224 of file lib/network/tcp/client.c.
| void tcp_client_signal_lost | ( | tcp_client_t * | client | ) |
Signal that connection was lost (triggers reconnection)
Definition at line 188 of file lib/network/tcp/client.c.