예제 #1
0
파일: Download.cs 프로젝트: xxy1991/cozy
 void ThreadDownload(DownloadTask task)
 {
     this.mTask = task;
     Parallel.For(0, 3, (i) =>
     {
         DownloadThread();
     });
     mLog.Info("Download all finish.");
     this.Finished();
 }
예제 #2
0
파일: Download.cs 프로젝트: xxy1991/cozy
 private void Process()
 {
     mLog.Info("Download process start,url:[{0}],filename;[{0}]", this.mUrl, this.mFilename);
     DownloadTask task = new DownloadTask();
     task.RemotePath = this.mUrl;
     task.LocalPath = this.mFilename;
     task.BlockSize = 1024 * 1024 * 3;
     if (task.InitTask())
     {
         this.ThreadDownload(task);
     }
 }
예제 #3
0
파일: Program.cs 프로젝트: xxy1991/cozy
        static void Main(string[] args)
        {
            task = new DownloadTask();
            task.RemotePath = @"http://speed.myzone.cn/pc_elive_1.1.rar"; //60M
            //task.RemotePath = @"http://cd002.www.duba.net/duba/install/2011/ever/duba160406_100_50.exe"; //17M
            task.LocalPath = @"d:\hehe.rar";
            task.BlockSize = 1024 * 1024 * 3;
            if (task.InitTask())
            {
                Console.WriteLine("begin download");
            }

            Console.ReadKey();

            master = new MasterPeer();
            master.Start(IPAddress.Any, 48360, new MasterPeerListener());
            List<KeyValuePair<string, int>> peerList = new List<KeyValuePair<string, int>>()
            {
                new KeyValuePair<string, int>("127.0.0.1", 48360),
                //new KeyValuePair<string, int>("10.20.208.27", 48235),
                //new KeyValuePair<string, int>("10.20.208.27", 48362),
                //new KeyValuePair<string, int>("10.20.221.119", 48360),
                //new KeyValuePair<string, int>("10.20.208.30", 48360), //wyf
                //new KeyValuePair<string, int>("10.20.208.38", 48390), //hym
                //new KeyValuePair<string, int>("10.20.208.55", 48390), //hsj
            };
            foreach (var i in peerList)
            {
                var peer = new Peer() { EndPoint = new IPEndPoint(IPAddress.Parse(i.Key), i.Value) };
                master.Connect(peer);
            }
            Console.ReadKey();
        }