mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-31 20:04:36 -04:00
Modified previous example into a Single Shot Search for RPC support.
Takes 2 - 3 minutes to run at the moment. Got to make it faster! git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5732 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
72d3c868e3
commit
1a1e453c7e
6 changed files with 674 additions and 553 deletions
59
libbitdht/src/example/bssdht.cc
Normal file
59
libbitdht/src/example/bssdht.cc
Normal file
|
@ -0,0 +1,59 @@
|
|||
|
||||
|
||||
#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 = "bsId";
|
||||
std::string bootstrapfile = "bdboot.txt";
|
||||
|
||||
BitDhtHandler dht(&ownId, port, appId, bootstrapfile);
|
||||
|
||||
/* install search node */
|
||||
bdNodeId searchId;
|
||||
bdStdRandomNodeId(&searchId);
|
||||
|
||||
std::cerr << "bssdht: searching for Id: ";
|
||||
bdStdPrintNodeId(std::cerr, &searchId);
|
||||
std::cerr << std::endl;
|
||||
|
||||
dht.FindNode(&searchId);
|
||||
|
||||
/* run your program */
|
||||
bdId resultId;
|
||||
uint32_t status;
|
||||
|
||||
resultId.id = searchId;
|
||||
|
||||
while(false == dht.SearchResult(&resultId, status))
|
||||
{
|
||||
sleep(10);
|
||||
}
|
||||
|
||||
std::cerr << "bssdht: Found Result:" << std::endl;
|
||||
|
||||
std::cerr << "\tId: ";
|
||||
bdStdPrintId(std::cerr, &resultId);
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::cerr << "\tstatus: " << status;
|
||||
std::cerr << std::endl;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue