From 463eb47011c036b19c79bffc33d893f58894dd05 Mon Sep 17 00:00:00 2001
From: Arvid Norberg
construct a session
parse .torrent-files and add them to the session (see bdecode() bencode())
+parse .torrent-files and add them to the session (see bdecode() bencode() and add_torrent())
main loop (see session)
@@ -213,7 +217,7 @@ the session, it conta
save resume data for all torrent_handles (optional, see -`write_resume_data()`_)
+write_resume_data())destruct session object
Each class and function is described in this manual.
There are a few typedefs in the libtorrent namespace which pulls in network types from the asio namespace. These are:
@@ -239,6 +243,7 @@ udp::endpoint
Which are the endpoint types used in libtorrent. An endpoint is an address with an associated port.
+For documentation on these types, please refer to the asio documentation.
+++void remove_torrent(torrent_handle const& h, int options = none); ++
remove_torrent() will close all peer connections associated with the torrent and tell +the tracker that we've stopped participating in the swarm. The optional second argument +options can be used to delete all the files downloaded by this torrent. To do this, pass +in the value session::delete_files. The removal of the torrent is asyncronous, there is +no guarantee that adding the same torrent immediately after it was removed will not throw +a duplicate_torrent exception.
+--void remove_torrent(torrent_handle const& h); torrent_handle find_torrent(sha_hash const& ih); std::vector<torrent_handle> get_torrents() const;
remove_torrent() will close all peer connections associated with the torrent and tell -the tracker that we've stopped participating in the swarm.
find_torrent() looks for a torrent with the given info-hash. In case there is such a torrent in the session, a torrent_handle to that torrent is returned. In case the torrent cannot be found, an invalid torrent_handle is returned.
@@ -1401,6 +1423,8 @@ struct torrent_handle entry write_resume_data() const; void force_reannounce() const; + void force_reannounce(boost::posix_time::time_duration) const; + void scrape_tracker() const; void connect_peer(asio::ip::tcp::endpoint const& adr, int source = 0) const; void set_tracker_login(std::string const& username @@ -1559,11 +1583,26 @@ thread, this operation is also asynchronous. Once the operation completes, thevoid force_reannounce() const; +void force_reannounce(boost::posix_time::time_duration) const;
force_reannounce() will force this torrent to do another tracker request, to receive new -peers. If the torrent is invalid, queued or in checking mode, this functions will throw -invalid_handle.
+peers. The second overload of force_reannounce that takes a time_duration as +argument will schedule a reannounce in that amount of time from now. ++++void scrape_tracker() const; ++
scrape_tracker() will send a scrape request to the tracker. A scrape request queries the +tracker for statistics such as total number of incomplete peers, complete peers, number of +downloads etc.
+This request will specifically update the num_complete and num_incomplete fields in +the torrent_status struct once it completes. When it completes, it will generate a +scrape_reply_alert. If it fails, it will generate a scrape_failed_alert.
user_agent this is the client identification to the tracker. @@ -2462,6 +2507,13 @@ Default is 10 minutes
(which it is by default), the DHT will only be used for torrents where all trackers in its tracker list has failed. Either by an explicit error message or a time out. +free_torrent_hashes determines whether or not the torrent's piece hashes +are kept in memory after the torrent becomes a seed or not. If it is set to +true the hashes are freed once the torrent is a seed (they're not +needed anymore since the torrent won't download anything more). If it's set +to false they are not freed. If they are freed, the torrent_info returned +by get_torrent_info() will return an object that may be incomplete, that +cannot be passed back to add_torrent() for instance.
+struct scrape_reply_alert: torrent_alert +{ + scrape_reply_alert(torrent_handle const& h + , int incomplete_ + , int complete_ + , std::string const& msg); + + int incomplete; + int complete; + + virtual std::auto_ptr<alert> clone() const; +}; ++
This alert is generated when a scrape request succeeds. incomplete< 15a2 /tt> +and complete is the data returned in the scrape response. These numbers +may be -1 if the reponse was malformed.
++struct scrape_failed_alert: torrent_alert +{ + scrape_failed_alert(torrent_handle const& h + , std::string const& msg); + + virtual std::auto_ptr<alert> clone() const; +}; ++
If a scrape request fails, this alert is generated. This might be due +to the tracker timing out, refusing connection or returning an http response +code indicating an error.
+This alert is generated when a HTTP seed name lookup fails. This alert is generated as severity level warning.
@@ -3363,7 +3450,8 @@ struct invalid_handle: std::exceptionThis is thrown by add_torrent() if the torrent already has been added to -the session.
+the session. Since remove_torrent() is asynchronous, this exception may +be thrown if the torrent is removed and then immediately added again.struct duplicate_torrent: std::exception { @@ -3484,7 +3572,7 @@ not, set error to a dThe default storage may compare file sizes and time stamps of the files.
void write_resume_data(entry& rd) const = 0; @@ -3986,12 +4074,6 @@ scripts.Project is hosted by sourceforge.