CTorrent
程序源码分析
姚旭晨
目录
前言
.....................................................................................................................................................
3
1.1
为什么要写这份文档
...........................................................................................................
3
1.2
客户端的选择
.......................................................................................................................
3
1.3 CTorrent
简介
........................................................................................................................
4
2.
准备工作
.........................................................................................................................................
5
2.1
知识储备
...............................................................................................................................
5
2.2
我对本篇源码分析的说明
...................................................................................................
5
3.
总述
.................................................................................................................................................
6
3.1 CTorrent
的命令行参数的意义
...........................................................................................
6
3.2 CTorrent
的状态栏的意义
...................................................................................................
7
3.3
各个类实现的具体实例
.......................................................................................................
7
3.4 BT
协议的特性和
CTorrent
的实现情况
.............................................................................
8
4.
源代码分析
...................................................................................................................................
10
4.1 ctorrent.cpp .......................................................................................................................... 10
4.2 downloader.cpp .................................................................................................................... 11
4.3 bencode.h ............................................................................................................................. 13
4.4 bitfield.h .............................................................................................................................. 15
4.4.1 class BitField ............................................................................................................ 15
4.5 btcontent.h ........................................................................................................................... 18
4.5.1 BTCACHE
结构体
..................................................................................................
18
4.5.2 class btContent ......................................................................................................... 18
4.6 btfiles.h ................................................................................................................................ 30
4.6.2 Class btFiles ............................................................................................................. 31
4.7 btrequest.h ........................................................................................................................... 35
4.7.1 class RequestQueue .................................................................................................. 35
4.7.2 class PendingQueue ................................................................................................. 37
4.8 btstream.h ............................................................................................................................ 38
4.8.1 class btStream ........................................................................................................... 38
4.9 bufio.h .................................................................................................................................. 41
4.9.1 class BufIo ................................................................................................................ 41
4.10 connect_nonb.h ................................................................................................................. 43
4.11 httpencode.h ...................................................................................................................... 43
4.12 iplist.h ................................................................................................................................ 45
4.12.1 struct _iplist ............................................................................................................ 45