A lightweight asynchronous message-passing library written in C.
This library provides a minimal asynchronous server–client messaging model based on non-blocking sockets and an event-driven architecture.
Messages follow a line-based protocol.
The implementation is intentionally small and is intended for an experimental distributed system rather than general-purpose messaging infrastructure.
This library was originally developed as the communication layer for the Direct-Access MapReduce prototype.
In that system, it is used for master–worker coordination such as task assignment and control messaging.
Although developed for that system, the library can also be used in other server–client applications.
Communication is driven by an event engine, with callbacks invoked when I/O events occur.
Messages follow a line-based protocol.
A message is considered complete when a newline character (\n) is received.
- Accepts client connections
- Invokes a request-handling callback whenever a message is received
- The handler may optionally send a reply to the client
- Sends requests to the server
- Receives replies asynchronously through an on-reply callback (
on_completion_cb)
This library is intended for experimental use and does not aim to provide production-level messaging features.
Error handling and edge-case coverage are intentionally minimal.
Dependencies:
ep_enginepthread
The CMake configuration automatically fetches the dependencies.
# 1. Clone the repository
git clone https://github.com/wjnlim/msg_pass.git
# 2. Create a build directory
mkdir msg_pass/build
cd msg_pass/build
# 3. Configure with CMake
cmake -DCMAKE_INSTALL_PREFIX=<your install directory> ..
# 4. Build and install the library
cmake --build . --target installExample programs are available in the repository:
Compile example server:
# hello_server
gcc hello_server.c -o hello_server -I <your install directory>/include/ <your install directory>/lib/libmsg_pass.a -lpthreadCompile example client:
# hello_client
gcc hello_client.c -o hello_client -I <your install directory>/include/ <your install directory>/lib/libmsg_pass.a -lpthreadRun example:
# start server
./hello_server
# run client
./hello_client <server ip> <client name> <use_threadpool> <number_of_requests>To compile your program using this library:
gcc your_prog.c -o your_prog -I <your install directory>/include \
<your install directory>/lib/libep_engine.a -lpthread