ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
tcp_client Struct Reference

TCP client connection and state management. More...

#include <lib/network/tcp/client.h>

Data Fields

socket_t sockfd
 
atomic_bool connection_active
 
atomic_bool connection_lost
 
atomic_bool should_reconnect
 
uint32_t my_client_id
 
char server_ip [256]
 
mutex_t send_mutex
 
bool encryption_enabled
 
audio_context_t audio_ctx
 
tcp_client_audio_packet_t audio_send_queue [256]
 
int audio_send_queue_head
 
int audio_send_queue_tail
 
mutex_t audio_send_queue_mutex
 
cond_t audio_send_queue_cond
 
bool audio_send_queue_initialized
 
atomic_bool audio_sender_should_exit
 
asciichat_thread_t audio_capture_thread
 
asciichat_thread_t audio_sender_thread
 
bool audio_capture_thread_created
 
bool audio_sender_thread_created
 
atomic_bool audio_capture_thread_exited
 
asciichat_thread_t data_reception_thread
 
bool data_thread_created
 
atomic_bool data_thread_exited
 
uint32_t last_active_count
 
bool server_state_initialized
 
bool should_clear_before_next_frame
 
asciichat_thread_t capture_thread
 
bool capture_thread_created
 
atomic_bool capture_thread_exited
 
asciichat_thread_t ping_thread
 
bool ping_thread_created
 
atomic_bool ping_thread_exited
 
bool has_tty
 
atomic_bool is_first_frame_of_connection
 
tty_info_t tty_info
 
crypto_handshake_context_t crypto_ctx
 
bool crypto_initialized
 

Detailed Description

TCP client connection and state management.

Encapsulates all state for a single TCP client connection, including:

  • Network connection state (socket, server info, connection flags)
  • Thread management (handles, creation flags, exit flags)
  • Audio processing state (queues, buffers, context)
  • Protocol state (packet tracking, server state)
  • Display state (terminal capabilities, TTY info)
  • Crypto state (handshake context, encryption flags)

Ownership Model

Thread Safety

  • Atomic fields: Safe for concurrent read/write without locks
  • Mutex-protected fields: Acquire mutex before access
  • Immutable after init: Safe for concurrent reads
See also
tcp_server_t For server-side equivalent structure

Definition at line 104 of file lib/network/tcp/client.h.

Field Documentation

◆ audio_capture_thread

asciichat_thread_t tcp_client::audio_capture_thread

Audio capture thread handle

Definition at line 162 of file lib/network/tcp/client.h.

◆ audio_capture_thread_created

bool tcp_client::audio_capture_thread_created

Audio capture thread was successfully created

Definition at line 168 of file lib/network/tcp/client.h.

Referenced by tcp_client_create(), and tcp_client_destroy().

◆ audio_capture_thread_exited

atomic_bool tcp_client::audio_capture_thread_exited

Audio capture thread has exited

Definition at line 174 of file lib/network/tcp/client.h.

Referenced by tcp_client_create(), and tcp_client_destroy().

◆ audio_ctx

audio_context_t tcp_client::audio_ctx

Audio capture and playback context

Definition at line 138 of file lib/network/tcp/client.h.

Referenced by tcp_client_create().

◆ audio_send_queue

tcp_client_audio_packet_t tcp_client::audio_send_queue[256]

Queue of audio packets awaiting transmission

Definition at line 141 of file lib/network/tcp/client.h.

Referenced by tcp_client_create().

◆ audio_send_queue_cond

cond_t tcp_client::audio_send_queue_cond

Condition variable for audio queue signaling

Definition at line 153 of file lib/network/tcp/client.h.

Referenced by tcp_client_create(), and tcp_client_destroy().

◆ audio_send_queue_head

int tcp_client::audio_send_queue_head

Write position in audio send queue (producer)

Definition at line 144 of file lib/network/tcp/client.h.

Referenced by tcp_client_create().

◆ audio_send_queue_initialized

bool tcp_client::audio_send_queue_initialized

Audio send queue has been initialized

Definition at line 156 of file lib/network/tcp/client.h.

Referenced by tcp_client_create().

◆ audio_send_queue_mutex

mutex_t tcp_client::audio_send_queue_mutex

Mutex protecting audio send queue access

Definition at line 150 of file lib/network/tcp/client.h.

Referenced by tcp_client_create(), and tcp_client_destroy().

◆ audio_send_queue_tail

int tcp_client::audio_send_queue_tail

Read position in audio send queue (consumer)

Definition at line 147 of file lib/network/tcp/client.h.

Referenced by tcp_client_create().

◆ audio_sender_should_exit

atomic_bool tcp_client::audio_sender_should_exit

Signal audio sender thread to exit

Definition at line 159 of file lib/network/tcp/client.h.

Referenced by tcp_client_create().

◆ audio_sender_thread

asciichat_thread_t tcp_client::audio_sender_thread

Audio sender thread handle

Definition at line 165 of file lib/network/tcp/client.h.

◆ audio_sender_thread_created

bool tcp_client::audio_sender_thread_created

Audio sender thread was successfully created

Definition at line 171 of file lib/network/tcp/client.h.

Referenced by tcp_client_create().

◆ capture_thread

asciichat_thread_t tcp_client::capture_thread

Webcam capture thread handle

Definition at line 203 of file lib/network/tcp/client.h.

◆ capture_thread_created

bool tcp_client::capture_thread_created

Capture thread was successfully created

Definition at line 206 of file lib/network/tcp/client.h.

Referenced by tcp_client_create(), and tcp_client_destroy().

◆ capture_thread_exited

atomic_bool tcp_client::capture_thread_exited

Capture thread has exited

Definition at line 209 of file lib/network/tcp/client.h.

Referenced by tcp_client_create(), and tcp_client_destroy().

◆ connection_active

◆ connection_lost

atomic_bool tcp_client::connection_lost

Connection was lost (triggers reconnection logic)

Definition at line 116 of file lib/network/tcp/client.h.

Referenced by tcp_client_cleanup(), tcp_client_connect(), tcp_client_create(), tcp_client_is_lost(), and tcp_client_signal_lost().

◆ crypto_ctx

◆ crypto_initialized

bool tcp_client::crypto_initialized

◆ data_reception_thread

asciichat_thread_t tcp_client::data_reception_thread

Data reception thread handle

Definition at line 181 of file lib/network/tcp/client.h.

◆ data_thread_created

bool tcp_client::data_thread_created

Data reception thread was successfully created

Definition at line 184 of file lib/network/tcp/client.h.

Referenced by tcp_client_create(), and tcp_client_destroy().

◆ data_thread_exited

atomic_bool tcp_client::data_thread_exited

Data reception thread has exited

Definition at line 187 of file lib/network/tcp/client.h.

Referenced by tcp_client_create(), and tcp_client_destroy().

◆ encryption_enabled

bool tcp_client::encryption_enabled

Encryption is enabled for this connection

Definition at line 131 of file lib/network/tcp/client.h.

Referenced by tcp_client_create().

◆ has_tty

bool tcp_client::has_tty

Client has a TTY (not redirected output)

Definition at line 229 of file lib/network/tcp/client.h.

Referenced by tcp_client_create().

◆ is_first_frame_of_connection

atomic_bool tcp_client::is_first_frame_of_connection

This is the first frame of a new connection

Definition at line 232 of file lib/network/tcp/client.h.

Referenced by tcp_client_create().

◆ last_active_count

uint32_t tcp_client::last_active_count

Last active client count received from server

Definition at line 190 of file lib/network/tcp/client.h.

Referenced by tcp_client_create().

◆ my_client_id

uint32_t tcp_client::my_client_id

Client ID assigned by server during initial handshake

Definition at line 122 of file lib/network/tcp/client.h.

Referenced by tcp_client_close(), tcp_client_connect(), tcp_client_create(), and tcp_client_get_id().

◆ ping_thread

asciichat_thread_t tcp_client::ping_thread

Ping/keepalive thread handle

Definition at line 216 of file lib/network/tcp/client.h.

◆ ping_thread_created

bool tcp_client::ping_thread_created

Ping thread was successfully created

Definition at line 219 of file lib/network/tcp/client.h.

Referenced by tcp_client_create(), and tcp_client_destroy().

◆ ping_thread_exited

atomic_bool tcp_client::ping_thread_exited

Ping thread has exited

Definition at line 222 of file lib/network/tcp/client.h.

Referenced by tcp_client_create(), and tcp_client_destroy().

◆ send_mutex

◆ server_ip

char tcp_client::server_ip[256]

Server IP address (for display and reconnection)

Definition at line 125 of file lib/network/tcp/client.h.

Referenced by tcp_client_cleanup(), tcp_client_connect(), and tcp_client_create().

◆ server_state_initialized

bool tcp_client::server_state_initialized

Server state packet has been received and processed

Definition at line 193 of file lib/network/tcp/client.h.

Referenced by tcp_client_create().

◆ should_clear_before_next_frame

bool tcp_client::should_clear_before_next_frame

Terminal should be cleared before next frame display

Definition at line 196 of file lib/network/tcp/client.h.

Referenced by tcp_client_create().

◆ should_reconnect

atomic_bool tcp_client::should_reconnect

Reconnection should be attempted

Definition at line 119 of file lib/network/tcp/client.h.

Referenced by tcp_client_cleanup(), tcp_client_connect(), and tcp_client_create().

◆ sockfd

◆ tty_info

tty_info_t tcp_client::tty_info

TTY information and capabilities

Definition at line 235 of file lib/network/tcp/client.h.

Referenced by tcp_client_create().


The documentation for this struct was generated from the following file: