Device Screen

Radikant Socket c 

Radikant Socket is a simple, cross-platform C library that provides a simple and consistent API for synchronous and asynchronous iTCP and UDP networking.

More Info

Radikant Socket is a lightweight, cross-platform C library that provides a simple and consistent API for TCP and UDP networking. It offers both synchronous and asynchronous interfaces, create clients and servers with minimal boilerplate. The library abstracts away platform-specific socket operations for Windows, Linux, and macOS.

The asynchronous API includes features such as automatic reconnect with exponential backoff, heartbeat support, and user-defined callbacks for connection, disconnection, and data events. Thread safety is maintained via internal mutexes, and the library handles low-level socket details like timeouts and safe sending, so users can focus on application logic rather than OS-specific networking quirks.

Example

FileEditViewProject
AsyncServer — TCP Listener
int main() {
rs_init();
rs_socket_t *server = rs_socket_create(RS_TCP);
if (rs_async_server_start(server, 12345,
on_client_connect,
on_client_data,
on_client_disconnect,
NULL) != RS_OK) {
return 1;
}
 
rs_async_server_stop(server);
rs_socket_close(server);
rs_cleanup();
 
return 0;
}
FileEditViewProject
AsyncClient — TCP Configuration
int main(void) {
rs_init();
rs_socket_t *client = rs_socket_create(RS_TCP);
rs_async_config_t cfg = {
.proto = RS_TCP,
.host = SERVER_IP,
.port = SERVER_PORT,
.reconnect_initial_ms = 1000,
.reconnect_max_ms = 5000,
.heartbeat_interval_ms = 3000,
.heartbeat_payload = "PING",
.heartbeat_len = 4
};
rs_async_client_start(client, &cfg,
on_connect, on_data, on_disconnect, NULL);
return 0;
}
Radikant
File
Edit
View
Window
Help
TCP_Client.log
[Client] TCP Client Starting... [Client] Connected to server! [Client] Server replied: Welcome to the Async Server! [Client] Server replied: Server confirms: Hello form Client A! [Client] Server replied: Server confirms: Report #1 [Client] Server replied: Server confirms: Report #2 [Client] Server replied: Server confirms: PING [Client] Server replied: Server confirms: Report #3 [Client] Server replied: Server confirms: PING [Client] Server replied: Server confirms: Report #4 [Client] Server replied: Server confirms: Report #5
Radikant
File
Edit
View
Window
Help
TCP_Server.log
[Server] Starting Async TCP Server on port 12345... [Server] Initialized [Server] New connection from 127.0.0.1:49413 [Server] 127.0.0.1:49413 says: Hello form Client A! [Server] 127.0.0.1:49413 says: Report #1 [Server] 127.0.0.1:49413 says: Report #2 [Server] 127.0.0.1:49413 says: PING [Server] 127.0.0.1:49413 says: Report #3 [Server] 127.0.0.1:49413 says: PING [Server] 127.0.0.1:49413 says: Report #4 [Server] 127.0.0.1:49413 says: Report #5