ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
tcp_client Struct Reference

TCP client connection state (network-layer only) More...

#include <include/ascii-chat/network/tcp/client.h>

Data Fields

socket_t sockfd
 
atomic_t connection_active
 
atomic_t connection_lost
 
atomic_t should_reconnect
 
uint32_t my_client_id
 
char server_ip [256]
 
mutex_t send_mutex
 
bool encryption_enabled
 

Detailed Description

TCP client connection state (network-layer only)

Encapsulates network-specific state for a single TCP client connection:

  • Socket file descriptor
  • Server address information
  • Connection state flags
  • Send mutex for thread-safe packet transmission
  • Encryption flag

Application-layer state (audio, threads, display, crypto) is now in app_client_t (network/client.h) to enable transport-agnostic design.

Ownership Model

  • Created by tcp_client_create() in main thread
  • Owned by connection management layer
  • Destroyed after network I/O is complete

Thread Safety

  • Atomic fields: Safe for concurrent read/write without locks
  • Mutex-protected fields: Acquire send_mutex before socket writes
  • Immutable after init: server_ip is set once, then read-only
See also
app_client_t For application-layer state
websocket_client_t For WebSocket transport equivalent

Definition at line 67 of file include/ascii-chat/network/tcp/client.h.

Field Documentation

◆ connection_active

atomic_t tcp_client::connection_active

Connection is active and ready for I/O operations

Definition at line 76 of file include/ascii-chat/network/tcp/client.h.

◆ connection_lost

atomic_t tcp_client::connection_lost

Connection was lost (triggers reconnection logic)

Definition at line 79 of file include/ascii-chat/network/tcp/client.h.

◆ encryption_enabled

bool tcp_client::encryption_enabled

Encryption is enabled for this connection

Definition at line 94 of file include/ascii-chat/network/tcp/client.h.

◆ my_client_id

uint32_t tcp_client::my_client_id

Client ID assigned by server during initial handshake

Definition at line 85 of file include/ascii-chat/network/tcp/client.h.

◆ send_mutex

mutex_t tcp_client::send_mutex

Mutex protecting concurrent socket send operations

Definition at line 91 of file include/ascii-chat/network/tcp/client.h.

◆ server_ip

char tcp_client::server_ip[256]

Server IP address (for display and reconnection)

Definition at line 88 of file include/ascii-chat/network/tcp/client.h.

Referenced by connection_attempt_tcp().

◆ should_reconnect

atomic_t tcp_client::should_reconnect

Reconnection should be attempted

Definition at line 82 of file include/ascii-chat/network/tcp/client.h.

◆ sockfd

socket_t tcp_client::sockfd

Socket file descriptor for server connection

Definition at line 73 of file include/ascii-chat/network/tcp/client.h.


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