From 19abdfb14a0fb5f5fd5393264eb834a28b0af96c Mon Sep 17 00:00:00 2001
From: Arvid Norberg
Date: Sun, 28 Mar 2004 22:44:40 +0000
Subject: [PATCH] *** empty log message ***
---
docs/manual.html | 15 +++++++++++----
docs/manual.rst | 16 ++++++++++++----
examples/client_test.cpp | 5 ++---
examples/simple_client.cpp | 4 +++-
include/libtorrent/session.hpp | 8 ++++----
src/session.cpp | 19 +++++++------------
6 files changed, 39 insertions(+), 28 deletions(-)
diff --git a/docs/manual.html b/docs/manual.html
index 1c9cff8c8..7168b2994 100755
--- a/docs/manual.html
+++ b/docs/manual.html
@@ -267,10 +267,11 @@ the session, it contains the m
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(
- 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);
torrent_handle add_torrent(
@@ -315,7 +316,11 @@ for checking, being checked or downloading) 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
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).
@@ -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. listen_on() returns true
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).
+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.
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
diff --git a/docs/manual.rst b/docs/manual.rst
index 3319d75b0..da5186e62 100755
--- a/docs/manual.rst
+++ b/docs/manual.rst
@@ -211,10 +211,11 @@ The ``session`` class has the following synopsis::
class session: public boost::noncopyable
{
- session(std::pair listen_port_range);
+ session(const fingerprint& print = libtorrent::fingerprint("LT, 0, 1, 0, 0));
+
session(
- std::pair listen_port_range
- , const fingerprint& print
+ const fingerprint& print
+ , std::pair listen_port_range
, const char* listen_interface = 0);
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
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
-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
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
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.
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
diff --git a/examples/client_test.cpp b/examples/client_test.cpp
index f3ec05865..e5cde9347 100755
--- a/examples/client_test.cpp
+++ b/examples/client_test.cpp
@@ -241,10 +241,9 @@ int main(int argc, char* argv[])
try
{
std::vector handles;
- session ses(
- std::make_pair(6881, 6889)
- , fingerprint("LT", 0, 1, 0, 0));
+ session ses(fingerprint("LT", 0, 1, 0, 0));
+ ses.listen_on(std::make_pair(6881, 6889));
ses.set_upload_rate_limit(100000);
ses.set_http_settings(settings);
// ses.set_severity_level(alert::debug);
diff --git a/examples/simple_client.cpp b/examples/simple_client.cpp
index 0070488bf..4f53fe1bb 100755
--- a/examples/simple_client.cpp
+++ b/examples/simple_client.cpp
@@ -56,7 +56,9 @@ int main(int argc, char* argv[])
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);
in.unsetf(std::ios_base::skipws);
diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp
index 23504f578..3028e3c8d 100755
--- a/include/libtorrent/session.hpp
+++ b/include/libtorrent/session.hpp
@@ -161,7 +161,7 @@ namespace libtorrent
session_impl(
std::pair listen_port_range
- , const fingerprint& cl_fprint
+ , fingerprint const& cl_fprint
, const char* listen_interface);
void operator()();
@@ -255,10 +255,10 @@ namespace libtorrent
{
public:
- session(std::pair listen_port_range);
+ session(fingerprint const& print = fingerprint("LT", 0, 1, 0, 0));
session(
- std::pair listen_port_range
- , const fingerprint& print
+ fingerprint const& print
+ , std::pair listen_port_range
, const char* listen_interface = 0);
~session();
diff --git a/src/session.cpp b/src/session.cpp
index 973bd3303..af9a8c0ce 100755
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -274,10 +274,6 @@ namespace libtorrent { namespace detail
, m_download_rate(-1)
, 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 ----
std::srand((unsigned int)std::time(0));
@@ -386,7 +382,8 @@ namespace libtorrent { namespace detail
{
#endif
- open_listen_port();
+ if (m_listen_port_range.first != 0 && m_listen_port_range.second != 0)
+ open_listen_port();
std::vector > readable_clients;
std::vector > writable_clients;
@@ -835,9 +832,9 @@ namespace libtorrent
{
session::session(
- std::pair listen_port_range
- , const fingerprint& id
- , const char* listen_interface)
+ fingerprint const& id
+ , std::pair listen_port_range
+ , char const* listen_interface)
: m_impl(listen_port_range, id, listen_interface)
, m_checker_impl(m_impl)
, m_thread(boost::ref(m_impl))
@@ -854,14 +851,12 @@ namespace libtorrent
#endif
}
- session::session(std::pair listen_port_range)
- : m_impl(listen_port_range, fingerprint("LT",0,0,1,0))
+ session::session(fingerprint const& id)
+ : m_impl(std::make_pair(0, 0), id)
, m_checker_impl(m_impl)
, m_thread(boost::ref(m_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
boost::function0 test = boost::ref(m_impl);
assert(!test.empty());