Downloading Torrents¶
Simple Client¶
1
2 ClientEngine engine = new ClientEngine(new EngineSettings(downloadsPath, port));
3
4 Torrent torrent = Torrent.Load("test.torrent");
5 TorrentManager manager = new TorrentManager(torrent, downloadsPath, torrentDefaults);
6
7 engine.Register(manager);
8 manager.Start ();
9
Advanced Client¶
1
2 ClientEngine engine = new ClientEngine(new EngineSettings(downloadsPath, port));
3
4 //DHT
5 DhtListener dhtListner = new UdpListener (new IPEndPoint (IPAddress.Any, port));
6 DhtEngine dht = new DhtEngine (dhtListner);
7 engine.RegisterDht(dht);
8 dhtListner.Start();
9 //byte array of dht nodes can be null if you have never connect to DHT before today!
10 engine.DhtEngine.Start(nodes);
11
12 torrent = Torrent.Load("test.torrent");
13 TorrentManager manager = new TorrentManager(torrent, downloadsPath, torrentDefaults);
14
15 //FastResume code need a BencodedDictionnary
16 //If you jsut start the torrent, you have no fast resume
17 // but if you have download a part of the torrent you can save fast resume data
18 //(manager.SaveFastResume()) and restore it later to do a quicker load
19 manager.LoadFastResume(new FastResume (BEncDictFastResume));
20
21 engine.Register(manager);
22 manager.Start ();
23