2013-05-05 2 views
2

Iam 일하는 monotorrent의 dht 구현을 얻으려고하지만 난 그냥 모든 동료를 찾을 것 같습니다.Monotorrents DHT를 작동시키는 방법?

필자는 testclient와 dhttest처럼 그물에서 예제 코드 코드를 대부분 시도했습니다.

나는 여러 다른 infohashes로 시도했다.

누구나 작동 할 수 있습니까? 또는 devs를 어디서 찾을 수 있는지 알고 있습니까?

이 내 코드는 기압 모습입니다 :

using System; 
using System.Collections.Generic; 
using System.Text; 
using MonoTorrent.Dht; 
using MonoTorrent.Dht.Listeners; 
using System.Net; 
using System.IO; 
using MonoTorrent.Common; 
using MonoTorrent.Tracker.Listeners; 

namespace SampleClient 
{ 
    class Program 
    { 
    static void Main(string[] args) 
    { 

    string basePath = Environment.CurrentDirectory; 
    string torrentsPath = Path.Combine(basePath, "Torrents"); 
    Torrent torrent = null; 
    // If the torrentsPath does not exist, we want to create it 
    if (!Directory.Exists(torrentsPath)) 
     Directory.CreateDirectory(torrentsPath); 
    // For each file in the torrents path that is a .torrent file, load it into the engine. 
    foreach (string file in Directory.GetFiles(torrentsPath)) 
    { 
     if (file.EndsWith(".torrent")) 
     { 
      try 
      { 
       // Load the .torrent from the file into a Torrent instance 
       // You can use this to do preprocessing should you need to 
       torrent = Torrent.Load(file); 
       Console.WriteLine(torrent.InfoHash.ToString()); 
      } 
      catch (Exception e) 
      { 
       Console.Write("Couldn't decode {0}: ", file); 
       Console.WriteLine(e.Message); 
       continue; 
      } 
     } 
    } 
     DhtListener listener = new DhtListener(new IPEndPoint(IPAddress.Parse("192.168.2.3"), 10000)); 
     DhtEngine engine = new DhtEngine(listener); 

     //engine.RegisterDht(dht); 

     byte[] nodes = null; 
     if (File.Exists("mynodes")) 
      nodes = File.ReadAllBytes("mynodes"); 

     listener.Start(); 
     int i = 0; 
     bool running = true; 
     StringBuilder sb = new StringBuilder(1024); 
     while (running) 
     { 
      engine.Start(nodes); 

      while (Console.ReadLine() != "q") 
      { 
       engine.GetPeers(torrent.InfoHash); 
      } 
      File.WriteAllBytes("mynodes", engine.SaveNodes()); 
     } 
    } 
} 

}

답변

0

나는 아주 오래된 질문 알고, 나는 그것이 아무도 어쨌든, 그것을 대답 아직 한 이유는 확실하지 않다. 당신이 실제로 해발 동료 ADRESS을 unkonw하는 respone를 보낼 수 있도록

DhtListener listener = new DhtListener(new IPEndPoint(IPAddress.Parse("192.168.2.3"), 10000));

이 IP는 실제 IP되지 않습니다 : 문제는이 선 것 같다. 무엇을할까요? 자신의 주소를 등록하십시오.

관련 문제