A modern, header-only C++ RPC library built on Boost.Asio with coroutine support.
- Header-only: No compilation required, just include and use
- Async/Await: Built on C++20 coroutines with Boost.Asio
- Type-safe: Compile-time type checking for RPC calls
- Flexible Transport: TCP channel included, extensible for other transports
- Zero Dependencies: Only requires Boost.Asio and spdlog
- Cross-platform: Works on Linux, Windows, macOS, and even Emscripten/WebAssembly
#include <grlx/rpc/client.hpp>
#include <grlx/rpc/tcp_channel.hpp>
#include <grlx/rpc/encoder.hpp>
using namespace grlx::rpc;
asio::awaitable<void> example_client() {
// Create client with TCP channel
client<tcp_channel<binary_encoder>> rpc_client;
// Connect to server
co_await rpc_client.connect("localhost:8080");
// Make RPC call
auto result = co_await rpc_client.invoke<std::string>("hello", "World");
std::cout << "Result: " << result << std::endl;
}#include <grlx/rpc/server.hpp>
#include <grlx/rpc/tcp_channel.hpp>
#include <grlx/rpc/encoder.hpp>
using namespace grlx::rpc;
asio::awaitable<void> example_server() {
// Create server with TCP channel
server<tcp_channel<binary_encoder>> rpc_server;
// Register RPC handler
rpc_server.attach("hello", [](std::string name) -> std::string {
return "Hello, " + name + "!";
});
// Start listening
tcp::endpoint endpoint(tcp::v4(), 8080);
co_await rpc_server.start(endpoint);
}client.hpp: RPC client with async invokeserver.hpp: RPC server with dispatchertcp_channel.hpp: TCP transport implementationsession.hpp: Session managementdispatcher.hpp: Function call routingencoder.hpp: Message encoding/decodingbuffer_pool.hpp: Efficient buffer management
- C++20 compiler (GCC 10+, Clang 12+, MSVC 2019+)
- Boost 1.75+ (Asio)
- spdlog (for logging)
# As a subproject
meson subprojects download grlx-rpc
# In your meson.build
grlx_rpc_dep = dependency('grlx-rpc')MIT License - See LICENSE file for details