当前位置:首页 > libtorrent+API+手册(中文版) - 图文
? ?
? ? ?
?
? ?
swap_slots3() o hash_for_slot() o rename_file() o release_files() o delete_files() magnet links queuing
o downloading o seeding fast resume
o file format threads
storage allocation
o sparse allocation o full allocation o compact allocation extensions
o metadata from peers o HTTP seeding filename checks acknowledgments
o
概述
libtorrent库的接口由少量几个类组成。最主要的类是session类,它有一个为所有任务服务的主循环.
基本的用法如下:
? 创建一个session
? 打开 扩展(查看 add_extension()).
? 打开 DHT, LSD, UPnP, NAT-PMP 等 (查看 start_dht(), stop_dht(),
set_dht_settings(), dht_state(), start_lsd(), stop_lsd(), start_upnp(), stop_upnp 和start_natpmp(), stop_natpmp()); ? 解析 .torrent文件 并且把它们加入到session中(查看 bdecode(),
bencode()和add_torrent()) ? 主循环(查看 session)
? 查询事务句柄, 得到下载进度(查看torrent_handler类) ? 查询事务,得到下载信息。
? 在运行时从事务中增加或者删除下载任务。 ? 主循环(查看 session)
? 为任务句柄保存新下载的数据(可以查看save_resume_data()函数) ? 析构事务对象
每个类和函数在这个手册中被描述到
关于如何创建任务种子文件的描述,但看make_torrent函数 网络原语
在libtorrent名字空间中有一些宏定义,这些定义从asio名字空间中选出。它们是:
typedef asio::ip::address address;
typedef asio::ip::address_v4 address_v4; typedef asio::ip::address_v6 address_v6; using asio::ip::tcp; using asio::ip::udp;
这些在
这些端点类型在libtorrent库中被使用.一个端点是一个地址与相关端口的结合。
关于这些类型的文档,请查看相关asio的文件说明.
session
事务类有如下一些概要:
class session: public boost::noncopyable {
session(fingerprint const& print = libtorrent::fingerprint( \
, int flags = start_default_features | add_default_plugins);
session(
fingerprint const& print
, std::pair
, char const* listen_interface = 0
, int flags = start_default_features | add_default_plugins);
torrent_handle add_torrent(add_torrent_params const& params);
void pause(); void resume();
bool is_paused() const;
session_proxy abort();
enum options_t {
none = 0,
delete_files = 1 };
enum session_flags_t {
add_default_plugins = 1, start_default_features = 2 };
void remove_torrent(torrent_handle const& h, int options = none);
torrent_handle find_torrent(sha_hash const& ih); std::vector
void set_settings(session_settings const& settings); void set_pe_settings(pe_settings const& settings);
void set_upload_rate_limit(int bytes_per_second); int upload_rate_limit() const;
void set_download_rate_limit(int bytes_per_second); int download_rate_limit() const; void set_max_uploads(int limit); void set_max_connections(int limit);
void set_max_half_open_connections(int limit); int max_half_open_connections() const;
void set_peer_proxy(proxy_settings const& s); void set_web_seed_proxy(proxy_settings const& s); void set_tracker_proxy(proxy_settings const& s);
proxy_settings const& peer_proxy() const; proxy_settings const& web_seed_proxy() const; proxy_settings const& tracker_proxy() const;
int num_uploads() const; int num_connections() const;
bool load_asnum_db(char const* file); bool load_country_db(char const* file); int as_for_ip(address const& adr);
void load_state(entry const& ses_state); entry state() const;
void set_ip_filter(ip_filter const& f); ip_filter const& get_ip_filter() const;
session_status status() const;
cache_status get_cache_status() const;
bool is_listening() const;
unsigned short listen_port() const; bool listen_on(
std::pair
std::auto_ptr
alert const* wait_for_alert(time_duration max_wait); void set_alert_mask(int m);
size_t set_alert_queue_size_limit(size_t queue_size_limit_);
void add_extension(boost::function<
boost::shared_ptr
void start_dht(); void stop_dht();
void set_dht_settings(
dht_settings const& settings); entry dht_state() const;
void add_dht_node(std::pair
void add_dht_router(std::pair
共分享92篇相关文档