云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > libtorrent+API+手册(中文版) - 图文

libtorrent+API+手册(中文版) - 图文

  • 62 次阅读
  • 3 次下载
  • 2025/7/14 3:29:33

? ?

? ? ?

?

? ?

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;

这些在头文件中描述. 这些表述为以下几方面提供简易接口: tcp::endpoint udp::endpoint

这些端点类型在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 listen_port_range

, 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 get_torrents() const;

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 const& port_range , char const* interface = 0);

std::auto_ptr pop_alert();

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(torrent*)> ext);

void start_dht(); void stop_dht();

void set_dht_settings(

dht_settings const& settings); entry dht_state() const;

void add_dht_node(std::pair const& node);

void add_dht_router(std::pair const& node);

搜索更多关于: libtorrent+API+手册(中文版) - 图文 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

? ? ? ? ? ? ? ? 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 acknowledg

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com