|
ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
|
🌐 Cross-platform socket I/O with timeout management and connection handling More...
Go to the source code of this file.
Functions | |
| 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. | |
| ssize_t | recv_with_timeout (socket_t sockfd, void *buf, size_t len, uint64_t timeout_ns) |
| Receive data with timeout. | |
| int | accept_with_timeout (socket_t listenfd, struct sockaddr *addr, socklen_t *addrlen, uint64_t timeout_ns) |
| Accept connection with timeout. | |
| asciichat_error_t | set_socket_timeout (socket_t sockfd, uint64_t timeout_ns) |
| Set socket timeout. | |
| asciichat_error_t | set_socket_keepalive (socket_t sockfd) |
| Set socket keepalive. | |
| asciichat_error_t | set_socket_nonblocking (socket_t sockfd) |
| Set socket non-blocking. | |
| asciichat_error_t | socket_configure_buffers (socket_t sockfd) |
| Configure socket buffers and TCP_NODELAY for optimal performance. | |
| const char * | network_error_string () |
| Get human-readable error string for network errors. | |
| bool | connect_with_timeout (socket_t sockfd, const struct sockaddr *addr, socklen_t addrlen, int timeout_seconds) |
| Connect with timeout. | |
🌐 Cross-platform socket I/O with timeout management and connection handling
Definition in file network/network.c.
| int accept_with_timeout | ( | socket_t | listenfd, |
| struct sockaddr * | addr, | ||
| socklen_t * | addrlen, | ||
| uint64_t | timeout_ns | ||
| ) |
Accept connection with timeout.
| listenfd | Listening socket |
| addr | Client address structure |
| addrlen | Length of address structure |
| timeout_seconds | Timeout in seconds |
Definition at line 250 of file network/network.c.
References asciichat_errno, asciichat_errno_context, and error_code.
| bool connect_with_timeout | ( | socket_t | sockfd, |
| const struct sockaddr * | addr, | ||
| socklen_t | addrlen, | ||
| int | timeout_seconds | ||
| ) |
Connect with timeout.
| sockfd | Socket file descriptor |
| addr | Address to connect to |
| addrlen | Address length |
| timeout_seconds | Timeout in seconds |
Definition at line 441 of file network/network.c.
References error_code, and set_socket_nonblocking().
Referenced by server_connection_establish(), and tcp_client_connect().
| const char * network_error_string | ( | ) |
Get human-readable error string for network errors.
| error_code | Error code |
Definition at line 429 of file network/network.c.
Referenced by add_client(), server_connection_establish(), socket_configure_buffers(), and tcp_client_connect().
| ssize_t recv_with_timeout | ( | socket_t | sockfd, |
| void * | buf, | ||
| size_t | len, | ||
| uint64_t | timeout_ns | ||
| ) |
Receive data with timeout.
| sockfd | Socket file descriptor |
| buf | Buffer to receive data |
| len | Length of buffer |
| timeout_seconds | Timeout in seconds |
Definition at line 182 of file network/network.c.
Referenced by packet_receive(), and receive_packet_secure().
| 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.
| sockfd | Socket file descriptor |
| data | Data to send |
| len | Length of data |
| timeout_seconds | Timeout in seconds |
Definition at line 112 of file network/network.c.
Referenced by packet_send().
| asciichat_error_t set_socket_keepalive | ( | socket_t | sockfd | ) |
Set socket keepalive.
| sockfd | Socket file descriptor |
Definition at line 355 of file network/network.c.
| asciichat_error_t set_socket_nonblocking | ( | socket_t | sockfd | ) |
Set socket non-blocking.
| sockfd | Socket file descriptor |
Definition at line 371 of file network/network.c.
Referenced by connect_with_timeout().
| asciichat_error_t set_socket_timeout | ( | socket_t | sockfd, |
| uint64_t | timeout_ns | ||
| ) |
Set socket timeout.
| sockfd | Socket file descriptor |
| timeout_ns | Timeout in nanoseconds (converted to milliseconds for socket level) |
Sets socket-level timeouts (SO_RCVTIMEO/SO_SNDTIMEO) as a safety net fallback. Actual precision depends on platform: milliseconds on most systems, microseconds on some. Works in conjunction with application-level timeouts via socket_poll.
Definition at line 320 of file network/network.c.
Referenced by add_client().
| asciichat_error_t socket_configure_buffers | ( | socket_t | sockfd | ) |
Configure socket buffers and TCP_NODELAY for optimal performance.
| sockfd | Socket file descriptor |
Definition at line 387 of file network/network.c.
References network_error_string().
Referenced by server_connection_establish(), and tcp_client_connect().