*** empty log message ***

This commit is contained in:
Arvid Norberg 2004-03-28 22:44:40 +00:00
parent e801435223
commit 19abdfb14a
6 changed files with 39 additions and 28 deletions

View File

@ -267,10 +267,11 @@ the <tt class="literal"><span class="pre">session</span></tt>, it contains the m
class session: public boost::noncopyable class session: public boost::noncopyable
{ {
session(std::pair&lt;int, int&gt; listen_port_range); session(const fingerprint&amp; print = libtorrent::fingerprint(&quot;LT, 0, 1, 0, 0));
session( session(
std::pair&lt;int, int&gt; listen_port_range const fingerprint&amp; print
, const fingerprint&amp; print , std::pair&lt;int, int&gt; listen_port_range
, const char* listen_interface = 0); , const char* listen_interface = 0);
torrent_handle add_torrent( torrent_handle add_torrent(
@ -315,7 +316,11 @@ for checking, being checked or downloading) <tt class="literal"><span class="pre
as argument. If this is ommited, the client will get a default fingerprint stating as argument. If this is ommited, the client will get a default fingerprint stating
the version of libtorrent. The fingerprint is a short string that will be used in the version of libtorrent. The fingerprint is a short string that will be used in
the peer-id to identify the client and the client's version. For more details see the the peer-id to identify the client and the client's version. For more details see the
fingerprint class.</p> fingerprint class. The constructor that only takes a finger print will not open a
listen port for the session, to get it running you'll have to call <tt class="literal"><span class="pre">session::listen_on()</span></tt>.
The other constructor, that takes a port range and an interface as well as the fingerprint
will automatically try to listen on a port on the given interface. For more information about
the parameters, see <tt class="literal"><span class="pre">listen_on()</span></tt> function.</p>
<p><tt class="literal"><span class="pre">set_upload_rate_limit()</span></tt> set the maximum number of bytes allowed to be <p><tt class="literal"><span class="pre">set_upload_rate_limit()</span></tt> set the maximum number of bytes allowed to be
sent to peers per second. This bandwidth is distributed among all the peers. If sent to peers per second. This bandwidth is distributed among all the peers. If
you don't want to limit upload rate, you can set this to -1 (the default). you don't want to limit upload rate, you can set this to -1 (the default).
@ -336,6 +341,8 @@ os will decide which interface to listen on, otherwise it should be the ip-addre
of the interface you want the listener socket bound to. <tt class="literal"><span class="pre">listen_on()</span></tt> returns true of the interface you want the listener socket bound to. <tt class="literal"><span class="pre">listen_on()</span></tt> returns true
if it managed to open the socket, and false if it failed. If it fails, it will also if it managed to open the socket, and false if it failed. If it fails, it will also
generate an appropriate alert (<a class="reference" href="#listen-failed-alert">listen_failed_alert</a>).</p> generate an appropriate alert (<a class="reference" href="#listen-failed-alert">listen_failed_alert</a>).</p>
<p>The interface parameter can also be a hostname that will resolve to the device you
want to listen on.</p>
<p>The destructor of session will notify all trackers that our torrents has been shut down. <p>The destructor of session will notify all trackers that our torrents has been shut down.
If some trackers are down, they will timout. All this before the destructor of session If some trackers are down, they will timout. All this before the destructor of session
returns. So, it's adviced that any kind of interface (such as windows) are closed before returns. So, it's adviced that any kind of interface (such as windows) are closed before

View File

@ -211,10 +211,11 @@ The ``session`` class has the following synopsis::
class session: public boost::noncopyable class session: public boost::noncopyable
{ {
session(std::pair<int, int> listen_port_range); session(const fingerprint& print = libtorrent::fingerprint("LT, 0, 1, 0, 0));
session( session(
std::pair<int, int> listen_port_range const fingerprint& print
, const fingerprint& print , std::pair<int, int> listen_port_range
, const char* listen_interface = 0); , const char* listen_interface = 0);
torrent_handle add_torrent( torrent_handle add_torrent(
@ -263,7 +264,11 @@ The difference between the two constructors is that one of them takes a fingerpr
as argument. If this is ommited, the client will get a default fingerprint stating as argument. If this is ommited, the client will get a default fingerprint stating
the version of libtorrent. The fingerprint is a short string that will be used in the version of libtorrent. The fingerprint is a short string that will be used in
the peer-id to identify the client and the client's version. For more details see the the peer-id to identify the client and the client's version. For more details see the
fingerprint class. fingerprint class. The constructor that only takes a finger print will not open a
listen port for the session, to get it running you'll have to call ``session::listen_on()``.
The other constructor, that takes a port range and an interface as well as the fingerprint
will automatically try to listen on a port on the given interface. For more information about
the parameters, see ``listen_on()`` function.
``set_upload_rate_limit()`` set the maximum number of bytes allowed to be ``set_upload_rate_limit()`` set the maximum number of bytes allowed to be
sent to peers per second. This bandwidth is distributed among all the peers. If sent to peers per second. This bandwidth is distributed among all the peers. If
@ -289,6 +294,9 @@ of the interface you want the listener socket bound to. ``listen_on()`` returns
if it managed to open the socket, and false if it failed. If it fails, it will also if it managed to open the socket, and false if it failed. If it fails, it will also
generate an appropriate alert (listen_failed_alert_). generate an appropriate alert (listen_failed_alert_).
The interface parameter can also be a hostname that will resolve to the device you
want to listen on.
The destructor of session will notify all trackers that our torrents has been shut down. The destructor of session will notify all trackers that our torrents has been shut down.
If some trackers are down, they will timout. All this before the destructor of session If some trackers are down, they will timout. All this before the destructor of session
returns. So, it's adviced that any kind of interface (such as windows) are closed before returns. So, it's adviced that any kind of interface (such as windows) are closed before

View File

@ -241,10 +241,9 @@ int main(int argc, char* argv[])
try try
{ {
std::vector<torrent_handle> handles; std::vector<torrent_handle> handles;
session ses( session ses(fingerprint("LT", 0, 1, 0, 0));
std::make_pair(6881, 6889)
, fingerprint("LT", 0, 1, 0, 0));
ses.listen_on(std::make_pair(6881, 6889));
ses.set_upload_rate_limit(100000); ses.set_upload_rate_limit(100000);
ses.set_http_settings(settings); ses.set_http_settings(settings);
// ses.set_severity_level(alert::debug); // ses.set_severity_level(alert::debug);

View File

@ -56,7 +56,9 @@ int main(int argc, char* argv[])
try try
{ {
session s(std::make_pair(6881, 6889)); session s(
libtorrent::fingerprint("LT", 0, 1, 0, 0)
, std::make_pair(6881, 6889));
std::ifstream in(argv[1], std::ios_base::binary); std::ifstream in(argv[1], std::ios_base::binary);
in.unsetf(std::ios_base::skipws); in.unsetf(std::ios_base::skipws);

View File

@ -161,7 +161,7 @@ namespace libtorrent
session_impl( session_impl(
std::pair<int, int> listen_port_range std::pair<int, int> listen_port_range
, const fingerprint& cl_fprint , fingerprint const& cl_fprint
, const char* listen_interface); , const char* listen_interface);
void operator()(); void operator()();
@ -255,10 +255,10 @@ namespace libtorrent
{ {
public: public:
session(std::pair<int, int> listen_port_range); session(fingerprint const& print = fingerprint("LT", 0, 1, 0, 0));
session( session(
std::pair<int, int> listen_port_range fingerprint const& print
, const fingerprint& print , std::pair<int, int> listen_port_range
, const char* listen_interface = 0); , const char* listen_interface = 0);
~session(); ~session();

View File

@ -274,10 +274,6 @@ namespace libtorrent { namespace detail
, m_download_rate(-1) , m_download_rate(-1)
, m_incoming_connection(false) , m_incoming_connection(false)
{ {
assert(listen_port_range.first > 0);
assert(listen_port_range.first < listen_port_range.second);
assert(m_listen_interface.port > 0);
// ---- generate a peer id ---- // ---- generate a peer id ----
std::srand((unsigned int)std::time(0)); std::srand((unsigned int)std::time(0));
@ -386,7 +382,8 @@ namespace libtorrent { namespace detail
{ {
#endif #endif
open_listen_port(); if (m_listen_port_range.first != 0 && m_listen_port_range.second != 0)
open_listen_port();
std::vector<boost::shared_ptr<socket> > readable_clients; std::vector<boost::shared_ptr<socket> > readable_clients;
std::vector<boost::shared_ptr<socket> > writable_clients; std::vector<boost::shared_ptr<socket> > writable_clients;
@ -835,9 +832,9 @@ namespace libtorrent
{ {
session::session( session::session(
std::pair<int, int> listen_port_range fingerprint const& id
, const fingerprint& id , std::pair<int, int> listen_port_range
, const char* listen_interface) , char const* listen_interface)
: m_impl(listen_port_range, id, listen_interface) : m_impl(listen_port_range, id, listen_interface)
, m_checker_impl(m_impl) , m_checker_impl(m_impl)
, m_thread(boost::ref(m_impl)) , m_thread(boost::ref(m_impl))
@ -854,14 +851,12 @@ namespace libtorrent
#endif #endif
} }
session::session(std::pair<int, int> listen_port_range) session::session(fingerprint const& id)
: m_impl(listen_port_range, fingerprint("LT",0,0,1,0)) : m_impl(std::make_pair(0, 0), id)
, m_checker_impl(m_impl) , m_checker_impl(m_impl)
, m_thread(boost::ref(m_impl)) , m_thread(boost::ref(m_impl))
, m_checker_thread(boost::ref(m_checker_impl)) , m_checker_thread(boost::ref(m_checker_impl))
{ {
assert(listen_port_range.first > 0);
assert(listen_port_range.first < listen_port_range.second);
#ifndef NDEBUG #ifndef NDEBUG
boost::function0<void> test = boost::ref(m_impl); boost::function0<void> test = boost::ref(m_impl);
assert(!test.empty()); assert(!test.empty());