ihub is a lightweight C-based clientβserver framework for sending JSON messages over TCP or TLS connections.
It mimics WebSocket-style communication but does not fully implement the WebSocket protocol β itβs intended for learning and prototyping only.
.
βββ ihubserver.c
βββ ihubserver.h
βββ ihubclient.c
βββ ihubclient.h
βββ README.md
- ihubserver β a simple epoll-based server that accepts multiple clients and routes JSON messages based on an
"action"field. - ihubclient β a small client that connects to the server (over HTTP or HTTPS) and sends/receives JSON messages.
- Uses cJSON for JSON parsing and OpenSSL for optional TLS.
Youβll need:
gcc(or any C11 compiler)libssl-devandlibcjson-dev
Example:
gcc yourserver.c ihubserver.c -o server -lssl -lcrypto -lcjson
gcc yourclient.c ihubclient.c -o client -lssl -lcrypto -lcjsonStart the server:
./serverStart a client (example sketch):
startConnection("http://127.0.0.1:8080/");
On("hello", hello_handler);
Invoke("sayHello", (char*[]){"Alice"}, 1);Messages are plain JSON:
{
"action": "sayHello",
"params": ["Alice"]
}Server responses:
{
"response": "Hello Alice!"
}This project does not fully implement the WebSocket protocol β it uses a simplified handshake and raw JSON over TCP/TLS.
It is meant for educational and experimental use only, not production deployment.
A heartfelt thank you to Idir Belfodil for his invaluable support and encouragement during the developement of this project.