diff --git a/docs/index.html b/docs/index.html index bd9e70ff1..9ab1124c9 100755 --- a/docs/index.html +++ b/docs/index.html @@ -17,53 +17,53 @@
libtorrent is a C++ library that aims to be a good alternative to all the other bittorrent implementations around. It is a library and not a full featured client, although it comes with a working @@ -115,7 +115,7 @@ boost.filesystem boost.date_time and various other boost libraries and zlib.
To build libtorrent you need boost and bjam installed. Then you can use bjam to build libtorrent.
To make bjam work, you need to set the environment variable BOOST_ROOT to the @@ -146,11 +146,11 @@ loop scope" and "treat wchar_t as built-in type" to Yes.
TODO: more detailed build instructions.
The interface of libtorrent consists of a few classes. The main class is the session, it contains the main loop that serves all torrents.
The session class has the following synopsis:
class session: public boost::noncopyable @@ -196,7 +196,7 @@ increasing the port number until it succeeds or has failed 9 ports. This wil change in the future to give more control of the listen-port.
The torrent files are bencoded. There are two functions in libtorrent that can encode and decode bencoded data. They are:
@@ -233,7 +233,7 @@ entry e = bdecode(buf, buf + data_size);Now we just need to know how to retrieve information from the entry.
The entry class represents one node in a bencoded hierarchy. It works as a variant type, it can be either a list, a dictionary (std::map), an integer or a string. This is its synopsis:
@@ -303,7 +303,7 @@ if (i != dict.end()) exists.The torrent_info has the following synopsis:
class torrent_info @@ -385,12 +385,12 @@ be smaller. piece and info_hash() returns the 20-bytes sha1-hash for the info-section of the torrent file. For more information on the sha1_hash, see the big_number class.comment() returns the comment associated with the torrent. If there's no comment, -it will return an empty string. creation_date() returns a boost::posix_time::ptime_ +it will return an empty string. creation_date() returns a boost::posix_time::ptime object, representing the time when this torrent file was created. If there's no timestamp in the torrent file, this will return a date of january 1:st 1970.
You will usually have to store your torrent handles somewhere, since it's the object through which you retrieve infromation about the torrent and aborts the torrent. Its declaration looks like this:
@@ -404,13 +404,24 @@ struct torrent_handle void get_peer_info(std::vector<peer_info>& v); const torrent_info& get_torrent_info(); bool is_valid(); + + boost::filsystem::path save_path() const; + + sha1_hash info_hash() const; + + bool operator==(const torrent_handle&) const; + bool operator!=(const torrent_handle&) const; + bool operator<(const torrent_handle&) const; };The default constructor will initialize the handle to an invalid state. Which means you cannot perform any operation on it, unless you first assign it a valid handle. If you try to perform any operation they will simply return.
+save_path() returns the path that was given to add_torrent() when this torrent +was started.
+info_hash() returns the info hash for the torrent.
status() will return a structure with information about the status of this torrent. If the torrent_handle is invalid, it will throw invalid_handle exception. It contains the following fields:
@@ -431,6 +442,8 @@ struct torrent_status boost::posix_time::time_duration next_announce; std::size_t total_download; std::size_t total_upload; + float download_rate; + float upload_rate; std::vector<bool> pieces; std::size_t total_done; }; @@ -470,10 +483,13 @@ is a pure seeder. uploaded to all peers, accumulated, this session only.pieces is the bitmask that representw which pieces we have (set to true) and the pieces we don't have.
+download_rate and upload_rate are the total rates for all peers for this +torrent. These will usually have better precision than summing the rates from +all peers.
total_done is the total number of bytes of the file(s) that we have.
get_download_queue() takes a non-const reference to a vector which it will fill information about pieces that are partially downloaded or not downloaded at all but partially requested. The entry in the vector (partial_piece_info) looks like this:
@@ -505,7 +521,7 @@ When a piece fails a hash verification, single blocks may be redownloaded to see may pass then.get_peer_info() takes a reference to a vector that will be cleared and filled with one entry for each peer connected to this torrent, given the handle is valid. If the torrent_handle is invalid, it will throw invalid_handle exception. Each entry in @@ -530,6 +546,12 @@ struct peer_info peer_id id; std::vector<bool> pieces; int upload_limit; + int upload_ceiling; + + int downloading_piece_index; + int downloading_block_index; + int downloading_progress; + int downloading_total; };
The flags attribute tells you in which state the peer is. It is set to @@ -552,22 +574,34 @@ is using.
in the torrent. Each boolean tells you if the peer has that piece (if it's set to true) or if the peer miss that piece (set to false).upload_limit is the number of bytes per second we are allowed to send to this -peer every second. It may be -1 if there's no limit.
+peer every second. It may be -1 if there's no limit. The upload limits of all peers +should sum up to the upload limit set by session::set_upload_limit. +upload_ceiling is the current maximum allowed upload rate given the cownload +rate and share ratio. If the global upload rate is inlimited, the upload_limit +for every peer will be the same as their upload_ceiling.
+You can know which piece, and which part of that piece, that is currently being +downloaded from a specific peer by looking at the next four members. +downloading_piece_index is the index of the piece that is currently being downloaded. +This may be set to -1 if there's currently no piece downloading from this peer. If it is +>= 0, the other three members are valid. downloading_block_index is the index of the +block (or sub-piece) that is being downloaded. downloading_progress is the number +of bytes of this block we have received from the peer, and downloading_total is +the total number of bytes in this block.
Returns a const reference to the torrent_info object associated with this torrent. This reference is valid as long as the torrent_handle is valid, no longer. If the torrent_handle is invalid, invalid_handle exception will be thrown.
Returns true if this handle refers to a valid torrent and false if it hasn't been initialized or if the torrent it refers to has been aborted.
The address class represents a name of a network endpoint (usually referred to as IP-address) and a port number. This is the same thing as a sockaddr_in would contain. Its declaration looks like this:
@@ -600,7 +634,7 @@ while it does the DNS lookup, it returns a string that points to the address repip() will return the 32-bit ip-address as an integer. port() returns the port number.
You have some control over tracker requests through the http_settings object. You create it and fill it with your settings and the use session::set_http_settings() to apply them. You have control over proxy and authorization settings and also the user-agent @@ -618,6 +652,16 @@ struct http_settings int tracker_maximum_response_length; }; +
proxy_ip may be a hostname or ip to a http proxy to use. If this is +an empty string, no http proxy will be used.
+proxy_port is the port on which the http proxy listens. If proxy_ip +is empty, this will be ignored.
+proxy_login should be the login username for the http proxy, if this +empty, the http proxy will be trid to be used without authentication.
+proxy_password the password string for the http proxy.
+user_agent this is the client identification to the tracker. It will +be followed by the string "(libtorrent)" to identify that this library +is being used. This should be set to your client's name and version number.
tracker_timeout is the number of seconds the tracker connection will wait until it considers the tracker to have timed-out. Default value is 10 seconds.
@@ -628,10 +672,9 @@ on the uncompressed data. So, if you get 20 bytes of gzip response that'll expand to 2 megs, it will be interrupted before the entire response has been uncompressed (given your limit is lower than 2 megs). Default limit is 1 megabyte. -TODO: finish document http_settings
Both the peer_id and sha1_hash types are typedefs of the class big_number. It represents 20 bytes of data. Its synopsis follows:
@@ -652,7 +695,7 @@ public:The iterators gives you access to individual bytes.
This class creates sha1-hashes. Its declaration looks like this:
class hasher @@ -676,11 +719,11 @@ call reset() to reinitialize i For more info, see src/sha1.c.
There are a number of exceptions that can be thrown from different places in libtorrent, here's a complete list with description.
This exception is thrown when querying information from a torrent_handle that hasn't been initialized or that has become invalid.
@@ -691,7 +734,7 @@ struct invalid_handle: std::exception
This is thrown by session::add_torrent() if the torrent already has been added to the session.
@@ -702,7 +745,7 @@ struct duplicate_torrent: std::exception
This is thrown by bdecode() if the input data is not a valid bencoding.
struct invalid_encoding: std::exception @@ -712,7 +755,7 @@ struct invalid_encoding: std::exception
This is thrown from the accessors of entry if the data type of the entry doesn't match the type you want to extract from it.
@@ -723,7 +766,7 @@ struct type_error: std::runtime_error
This exception is thrown from the constructor of torrent_info if the given bencoded information doesn't meet the requirements on what information has to be present in a torrent file.
@@ -735,9 +778,9 @@ struct invalid_torrent_file: std::exception
This is an example of a program that will take a torrent-file as a parameter and print information about it to std out:
@@ -801,7 +844,7 @@ int main(int argc, char* argv[])
This is a simple client. It doesn't have much output to keep it simple:
#include <iostream> @@ -854,12 +897,12 @@ int main(int argc, char* argv[])
There's a mailing list.
You can usually find me as hydri in #btports @ irc.freenode.net.
Written by Arvid Norberg and Daniel Wallin. Copyright (c) 2003
Project is hosted by sourceforge.
diff --git a/docs/index.rst b/docs/index.rst index af02fbde5..4344cc47b 100755 --- a/docs/index.rst +++ b/docs/index.rst @@ -8,7 +8,7 @@ libtorrent =================== =============== .. _sourceforge page: http://www.sourceforge.net/projects/libtorrent -.. _mailing list: http://lists.sourceforge.net/lists/listinfo/libtorrent-discus +.. _mailing list: http://lists.sourceforge.net/lists/listinfo/libtorrent-discuss .. contents:: @@ -398,11 +398,11 @@ piece and ``info_hash()`` returns the 20-bytes sha1-hash for the info-section of torrent file. For more information on the ``sha1_hash``, see the big_number_ class. ``comment()`` returns the comment associated with the torrent. If there's no comment, -it will return an empty string. ``creation_date()`` returns a ``boost::posix_time::ptime_`` +it will return an empty string. ``creation_date()`` returns a `boost::posix_time::ptime`__ object, representing the time when this torrent file was created. If there's no timestamp in the torrent file, this will return a date of january 1:st 1970. -.. _boost::posix_time::ptime: http://www.boost.org/libs/date_time/doc/class_ptime.html +__ http://www.boost.org/libs/date_time/doc/class_ptime.html @@ -437,7 +437,7 @@ The default constructor will initialize the handle to an invalid state. Which me perform any operation on it, unless you first assign it a valid handle. If you try to perform any operation they will simply return. -``save_path()`` returns the path that were given to ``add_torrent()`` when this torrent +``save_path()`` returns the path that was given to ``add_torrent()`` when this torrent was started. ``info_hash()`` returns the info hash for the torrent. @@ -570,6 +570,11 @@ fields:: std::vector