ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
network.h File Reference

🌐 Core network I/O operations with timeout support More...

Go to the source code of this file.

Macros

Network Timeout Constants

Timeout values tuned for real-time video streaming. All timeouts are specified in seconds.

#define CONNECT_TIMEOUT   3
 Connection timeout in seconds (3 seconds)
 
#define SEND_TIMEOUT   5
 Send timeout in seconds (5 seconds)
 
#define RECV_TIMEOUT   15
 Receive timeout in seconds (15 seconds)
 
#define ACCEPT_TIMEOUT   3
 Accept timeout in seconds (3 seconds)
 
Test Environment Detection
#define network_is_test_environment()   ((int)is_test_environment())
 Check if we're in a test environment.
 
Socket Keepalive Settings

Keepalive settings to detect dead connections. TCP keepalive probes are sent when connection is idle to detect broken connections.

#define KEEPALIVE_IDLE   60
 Keepalive idle time in seconds (60 seconds)
 
#define KEEPALIVE_INTERVAL   10
 Keepalive interval in seconds (10 seconds)
 
#define KEEPALIVE_COUNT   8
 Keepalive probe count (8 probes)
 

Functions

Socket I/O Operations
ssize_t send_with_timeout (socket_t sockfd, const void *data, size_t len, int timeout_seconds)
 Send data with timeout using chunked transmission.
 
ssize_t recv_with_timeout (socket_t sockfd, void *buf, size_t len, int timeout_seconds)
 Receive data with timeout.
 
int accept_with_timeout (socket_t listenfd, struct sockaddr *addr, socklen_t *addrlen, int timeout_seconds)
 Accept connection with timeout.
 
bool connect_with_timeout (socket_t sockfd, const struct sockaddr *addr, socklen_t addrlen, int timeout_seconds)
 Connect to server with timeout.
 
Socket Configuration Functions
asciichat_error_t set_socket_timeout (socket_t sockfd, int timeout_seconds)
 Set socket timeout for send/receive operations.
 
asciichat_error_t set_socket_keepalive (socket_t sockfd)
 Enable TCP keepalive on socket.
 
asciichat_error_t set_socket_nonblocking (socket_t sockfd)
 Set socket to non-blocking mode.
 
asciichat_error_t socket_configure_buffers (socket_t sockfd)
 Configure socket buffers and TCP_NODELAY for optimal performance.
 
Error Reporting Functions
const char * network_error_string ()
 Get human-readable error string for network errors.
 

Detailed Description

🌐 Core network I/O operations with timeout support

Definition in file network.h.