Ejemplo n.º 1
0
 internal Torrent(TorrentClient client, BTorrent btorrent)
 {
     _client       = client;
     _btorrent     = btorrent;
     AnnounceTiers = new List <AnnounceTier>();
     foreach (IList <string> trackers in btorrent.Trackers)
     {
         AnnounceTiers.Add(new AnnounceTier(this, trackers.Select(client.GetOrCreateTracker).ToList()));
     }
 }
Ejemplo n.º 2
0
        public Peer(TorrentClient client, Torrent torrent, PeerInfo info)
        {
            _initiator = true;
            _client    = client;
            _torrent   = torrent;

            Console.WriteLine($"[{info.Ip}:{info.Port}] Connecting");

            _tcpClient = new TcpClient(info.Ip, info.Port);
            NetworkStream stream = _tcpClient.GetStream();

            _reader = new BeBinaryReader(stream);
            _writer = new BeBinaryWriter(stream);

            _readThread = new Thread(ReadThreadBody);
            _readThread.Start();

            SendHandshake();
        }