ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
include/ascii-chat/network/tcp/server.h
Go to the documentation of this file.
1
2#pragma once
3
4#include <stdint.h>
5#include <stdbool.h>
7#include <libplatform/atomic.h>
8#include "../../common.h"
9#include <libplatform/socket.h>
10#include <ascii-chat/uthash.h> // For UT_hash_handle
11
12// Forward declarations
13typedef struct tcp_client_entry tcp_client_entry_t;
14typedef struct tcp_server tcp_server_t;
15
30
41
43
45
⚙️ Common definitions, error codes, macros, and types shared throughout the application
struct platform_event_loop platform_event_loop_t
Definition event.h:11
void(* platform_event_accept_fn)(platform_event_stream_t *, void *)
Definition event.h:19
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:44
int socket_t
struct tcp_server tcp_server_t
void tcp_server_destroy(tcp_server_t *server)
struct tcp_client_entry tcp_client_entry_t
asciichat_error_t tcp_server_init(tcp_server_t *server, const tcp_server_config_t *config)
asciichat_error_t tcp_server_run(tcp_server_t *server)
bool bind_ipv6
Whether to bind IPv6 socket.
platform_event_accept_fn event_handler
Required asynchronous accept handler.
void * user_data
User data passed to each client handler.
bool bind_ipv4
Whether to bind IPv4 socket.
const char * ipv4_address
IPv4 bind address (NULL or empty = don't bind).
const char * ipv6_address
IPv6 bind address (NULL or empty = don't bind).
void(* tick_fn)(void *user_data)
Optional periodic callback on the tcp_server_run thread.
The useful part of tcp server is in event_loop, listen_socket, listen_socket6, running: together they...
platform_event_loop_t * event_loop
Owned while the asynchronous server runs.
atomic_t running
Server running flag (set false to shutdown).
tcp_server_config_t config
Server configuration.
socket_t listen_socket
IPv4 listen socket.
socket_t listen_socket6
IPv6 listen socket.