ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
network.h
Go to the documentation of this file.
1
75#pragma once
76
77#include "platform/socket.h"
78#include "tests/test_env.h"
79#include <sys/types.h>
80
98#define CONNECT_TIMEOUT 3
99
108#define SEND_TIMEOUT 5
109
118#define RECV_TIMEOUT 15
119
128#define ACCEPT_TIMEOUT 3
129
147#define network_is_test_environment() ((int)is_test_environment())
148
168#define KEEPALIVE_IDLE 60
169
177#define KEEPALIVE_INTERVAL 10
178
186#define KEEPALIVE_COUNT 8
187
215ssize_t send_with_timeout(socket_t sockfd, const void *data, size_t len, int timeout_seconds);
216
236ssize_t recv_with_timeout(socket_t sockfd, void *buf, size_t len, int timeout_seconds);
237
256int accept_with_timeout(socket_t listenfd, struct sockaddr *addr, socklen_t *addrlen, int timeout_seconds);
257
276bool connect_with_timeout(socket_t sockfd, const struct sockaddr *addr, socklen_t addrlen, int timeout_seconds);
277
300asciichat_error_t set_socket_timeout(socket_t sockfd, int timeout_seconds);
301
316
333
360
381const char *network_error_string();
382
/* Error Reporting Functions */
384
/* network */
asciichat_error_t
Error and exit codes - unified status values (0-255)
Definition error_codes.h:46
asciichat_error_t set_socket_timeout(socket_t sockfd, int timeout_seconds)
Set socket timeout for send/receive operations.
Definition network.c:436
asciichat_error_t set_socket_keepalive(socket_t sockfd)
Enable TCP keepalive on socket.
Definition network.c:461
asciichat_error_t set_socket_nonblocking(socket_t sockfd)
Set socket to non-blocking mode.
Definition network.c:477
ssize_t send_with_timeout(socket_t sockfd, const void *data, size_t len, int timeout_seconds)
Send data with timeout using chunked transmission.
Definition network.c:200
bool connect_with_timeout(socket_t sockfd, const struct sockaddr *addr, socklen_t addrlen, int timeout_seconds)
Connect to server with timeout.
Definition network.c:547
int accept_with_timeout(socket_t listenfd, struct sockaddr *addr, socklen_t *addrlen, int timeout_seconds)
Accept connection with timeout.
Definition network.c:346
const char * network_error_string()
Get human-readable error string for network errors.
Definition network.c:535
asciichat_error_t socket_configure_buffers(socket_t sockfd)
Configure socket buffers and TCP_NODELAY for optimal performance.
Definition network.c:493
ssize_t recv_with_timeout(socket_t sockfd, void *buf, size_t len, int timeout_seconds)
Receive data with timeout.
Definition network.c:272
int socket_t
Socket handle type (POSIX: int)
Definition socket.h:50
Cross-platform socket interface for ascii-chat.
Test environment detection utilities.