
Radikant Socket is a lightweight, cross-platform C library that provides a simple and consistent API for synchronous and asynchronous iTCP and UDP networking.
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, allowing developers to 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.
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;
}
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;
}