I want to use BitTorrent DHT library as distributed hash tables from within a C program. Therefore I downloaded and compiled it on my machine - worked flawless. Now I have an executable dht-example which outputs:
Usage: dht-example [-q] [-4] [-6] [-i filename] [-b address]...
port [address port]...
What can I do with this example? How to play with the DHT: Connect distributed machines, fill it or read hash tables from it?
Thanks lot Achim
dht-example.c
is a minimalistic example provided in the mentioned DHT library.
After running make
for compilatation you are supposed to run ./example-dht 6882 67.215.246.10 6881
. This will open a listening UDP socket on local port 6882 for talking to the DHT network.
But before your new peer is able to connect to the network, it needs at least one connected peer from which it can get more peers. This is where the third and fourth parameter/argument comes into action. It is the IP address and port combination of a known good node on the network, in this case router.bittorrent.com
. This process is called bootstraping.
The program does not accept instructions from standard input, but instead via kernel signals SIGINT
, SIGUSR1
and SIGUSR2
. Use kill -L
to list signal numbers on your machine and then command ps aux | grep example-dht
while example-dht
is running to obtain the process ID of example-dht
.
For starting a search for peers of the infohash, hardcoded in dht-example.c
, issue the command kill -XX YYYYY
, where XX
is the number of the SIGUSR1
signal and YYYYY
is the process ID of dht-example
. Observe the standard output of the dht-example
program.
For dumping other nodes in our bucket and bucket 0, issue the command kill -XX YYYYY
, where XX
is the number of the SIGUSR2
signal and YYYYY
is the process ID of dht-example
. Observe the standard output of the dht-example
program.
For stopping dht-exmample
, issue the command kill -XX YYYYY
where XX
is the number of the SIGINT
signal and YYYYY
is the process ID of dht-example
. Observe the standard output of the dht-example
program.