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.