C# 如何让Monotorrents DHT正常工作?
我试图让monotorrent的dht实现工作,但我似乎找不到任何同行 我尝试了网络上可用的大多数示例代码,如testclient和dhttest 我尝试了几种不同的InfoHash 这里有人让它工作了吗?或者你知道我在哪里可以找到开发人员吗 下面是我的代码的外观:C# 如何让Monotorrents DHT正常工作?,c#,networking,bittorrent,dht,monotorrent,C#,Networking,Bittorrent,Dht,Monotorrent,我试图让monotorrent的dht实现工作,但我似乎找不到任何同行 我尝试了网络上可用的大多数示例代码,如testclient和dhttest 我尝试了几种不同的InfoHash 这里有人让它工作了吗?或者你知道我在哪里可以找到开发人员吗 下面是我的代码的外观: using System; using System.Collections.Generic; using System.Text; using MonoTorrent.Dht; using MonoTorrent.Dht.List
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());
}
}
}
}我知道这是一个非常古老的问题,我不知道为什么仍然没有人能回答它。问题似乎在于这一行:
DhtListener listener=newdhtlistener(new-IPEndPoint(IPAddress.Parse(“192.168.2.3”),10000))代码>
这个ip不是真正的ip,所以您实际上需要asl对等方将响应发送到未知地址。
怎么办?登记你自己的地址