ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
network/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#ifdef NDEBUG
109#define SEND_TIMEOUT 5
110#else
111#define SEND_TIMEOUT 1
112#endif
113
124#ifdef NDEBUG
125#define RECV_TIMEOUT 1
126#else
127#define RECV_TIMEOUT 1
128#endif
129
139#ifdef NDEBUG
140#define ACCEPT_TIMEOUT 3
141#else
142#define ACCEPT_TIMEOUT 1
143#endif
144
162#define network_is_test_environment() ((int)is_test_environment())
163
183#define KEEPALIVE_IDLE 60
184
192#define KEEPALIVE_INTERVAL 10
193
201#define KEEPALIVE_COUNT 8
202
230ssize_t send_with_timeout(socket_t sockfd, const void *data, size_t len, uint64_t timeout_ns);
231
251ssize_t recv_with_timeout(socket_t sockfd, void *buf, size_t len, uint64_t timeout_ns);
252
271int accept_with_timeout(socket_t listenfd, struct sockaddr *addr, socklen_t *addrlen, uint64_t timeout_ns);
272
291bool connect_with_timeout(socket_t sockfd, const struct sockaddr *addr, socklen_t addrlen, int timeout_seconds);
292
316
331
348
375
396const char *network_error_string();
397
/* Error Reporting Functions */
399
/* network */
unsigned long long uint64_t
Definition common.h:59
asciichat_error_t
Error and exit codes - unified status values (0-255)
Definition error_codes.h:49
asciichat_error_t set_socket_timeout(socket_t sockfd, uint64_t timeout_ns)
Set socket timeout for send/receive operations.
asciichat_error_t set_socket_keepalive(socket_t sockfd)
Enable TCP keepalive on socket.
ssize_t recv_with_timeout(socket_t sockfd, void *buf, size_t len, uint64_t timeout_ns)
Receive data with timeout.
asciichat_error_t set_socket_nonblocking(socket_t sockfd)
Set socket to non-blocking mode.
bool connect_with_timeout(socket_t sockfd, const struct sockaddr *addr, socklen_t addrlen, int timeout_seconds)
Connect to server with timeout.
int accept_with_timeout(socket_t listenfd, struct sockaddr *addr, socklen_t *addrlen, uint64_t timeout_ns)
Accept connection with timeout.
ssize_t send_with_timeout(socket_t sockfd, const void *data, size_t len, uint64_t timeout_ns)
Send data with timeout using chunked transmission.
const char * network_error_string()
Get human-readable error string for network errors.
asciichat_error_t socket_configure_buffers(socket_t sockfd)
Configure socket buffers and TCP_NODELAY for optimal performance.
int socket_t