简体   繁体   中英

C++ implementation of DHT

I am looking for opensource implementations of Kademlia DHT in C/C++. It must be lightweight and crossplatform (win/linux/mac).

It must be able to post information to DHT and retrieve it.

OpenDHT is a lightweight Kademlia DHT in C++11. The API is very simple:

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);

It supports compiling with LLVM or GCC on OS X, Linux and Windows.

LibTorrent's Kademlia DHT is written in C++ and is well documented.
Here is example code with immutable and mutable get/put operations: https://github.com/arvidn/libtorrent/blob/master/tools/dht_put.cpp

I have found a BitTorrent DHT library , used by Transmission. It is written in pure C, but it can be easily used from C++.

I am using it in my C++ project. It works well but requires an external cryptographic hash and randomization functions.

What's wrong with maidsafe-dht ?

You could try bitdht used by retroshare.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM