mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-26 05:35:13 -05:00
* Improved udpbitdht tests.
* Added Simple example - so others can understand how to interface with bitdht. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3724 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
33282bfc77
commit
cbdd08cd34
7 changed files with 1401 additions and 515 deletions
42
libbitdht/src/example/bdexample.cc
Normal file
42
libbitdht/src/example/bdexample.cc
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
|
||||
|
||||
#include "bitdht/bdiface.h"
|
||||
#include "bitdht/bdstddht.h"
|
||||
#include "bdhandler.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
/* startup dht : with a random id! */
|
||||
bdNodeId ownId;
|
||||
bdStdRandomNodeId(&ownId);
|
||||
|
||||
uint16_t port = 6775;
|
||||
std::string appId = "exId";
|
||||
std::string bootstrapfile = "bdboot.txt";
|
||||
|
||||
BitDhtHandler dht(&ownId, port, appId, bootstrapfile);
|
||||
|
||||
/* run your program */
|
||||
while(1)
|
||||
{
|
||||
bdNodeId searchId;
|
||||
bdStdRandomNodeId(&searchId);
|
||||
|
||||
dht.FindNode(&searchId);
|
||||
|
||||
sleep(180);
|
||||
|
||||
dht.DropNode(&searchId);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue