OpenDHT是 C++11 中的轻量级 Kademlia DHT。API 非常简单:
dht::DhtRunner node;
// Launch a dht node on a new thread, using a
// generated RSA key pair, and listen on port 4222.
node.run(4222, dht::crypto::generateIdentity(), true);
// Join the network through any running node,
// here using a known bootstrap node.
node.bootstrap("bootstrap.jami.net", "4222");
// put some data on the dht
std::vector<uint8_t> some_data(5, 10);
node.put("unique_key", some_data);
Run Code Online (Sandbox Code Playgroud)
它支持在 OS X、Linux 和 Windows 上使用 LLVM 或 GCC 进行编译。