From c7b4f49d5aaa9448036b90efc753d2ed66ade3bf Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 4 May 2007 06:47:32 +0000 Subject: [PATCH] moved initialization of multicast addresses from global initializers to local constructors to avoid WSAStartup issues on windows --- include/libtorrent/lsd.hpp | 3 +++ include/libtorrent/upnp.hpp | 3 +++ src/lsd.cpp | 12 ++++++------ src/upnp.cpp | 12 ++++++------ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/include/libtorrent/lsd.hpp b/include/libtorrent/lsd.hpp index 09be0c9ed..9ffbcdfc3 100644 --- a/include/libtorrent/lsd.hpp +++ b/include/libtorrent/lsd.hpp @@ -65,6 +65,9 @@ public: private: + static address_v4 lsd_multicast_address; + static udp::endpoint lsd_multicast_endpoint; + void resend_announce(asio::error_code const& e, std::string msg); void on_announce(asio::error_code const& e , std::size_t bytes_transferred); diff --git a/include/libtorrent/upnp.hpp b/include/libtorrent/upnp.hpp index 17c80df81..68bb57d22 100644 --- a/include/libtorrent/upnp.hpp +++ b/include/libtorrent/upnp.hpp @@ -72,6 +72,9 @@ public: private: + static address_v4 upnp_multicast_address; + static udp::endpoint upnp_multicast_endpoint; + enum { num_mappings = 2 }; enum { default_lease_time = 3600 }; diff --git a/src/lsd.cpp b/src/lsd.cpp index f3ca72403..f73b4c019 100644 --- a/src/lsd.cpp +++ b/src/lsd.cpp @@ -46,12 +46,8 @@ POSSIBILITY OF SUCH DAMAGE. using boost::bind; using namespace libtorrent; -namespace -{ - // Bittorrent Local discovery multicast address and port - address_v4 lsd_multicast_address = address_v4::from_string("239.192.152.143"); - udp::endpoint lsd_multicast_endpoint(lsd_multicast_address, 6771); -} +address_v4 lsd::lsd_multicast_address; +udp::endpoint lsd::lsd_multicast_endpoint; lsd::lsd(io_service& ios, address const& listen_interface , peer_callback_t const& cb) @@ -61,6 +57,10 @@ lsd::lsd(io_service& ios, address const& listen_interface , m_broadcast_timer(ios) , m_disabled(false) { + // Bittorrent Local discovery multicast address and port + lsd_multicast_address = address_v4::from_string("239.192.152.143"); + lsd_multicast_endpoint = udp::endpoint(lsd_multicast_address, 6771); + #if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING) m_log.open("lsd.log", std::ios::in | std::ios::out | std::ios::trunc); #endif diff --git a/src/upnp.cpp b/src/upnp.cpp index 4c216ca56..8b7f8354f 100644 --- a/src/upnp.cpp +++ b/src/upnp.cpp @@ -47,12 +47,8 @@ POSSIBILITY OF SUCH DAMAGE. using boost::bind; using namespace libtorrent; -namespace -{ - // UPnP multicast address and port - address_v4 upnp_multicast_address = address_v4::from_string("239.255.255.250"); - udp::endpoint upnp_multicast_endpoint(upnp_multicast_address, 1900); -} +address_v4 upnp::upnp_multicast_address; +udp::endpoint upnp::upnp_multicast_endpoint; upnp::upnp(io_service& ios, address const& listen_interface , std::string const& user_agent, portmap_callback_t const& cb) @@ -68,6 +64,10 @@ upnp::upnp(io_service& ios, address const& listen_interface , m_disabled(false) , m_closing(false) { + // UPnP multicast address and port + upnp_multicast_address = address_v4::from_string("239.255.255.250"); + upnp_multicast_endpoint = udp::endpoint(upnp_multicast_address, 1900); + #ifdef TORRENT_UPNP_LOGGING m_log.open("upnp.log", std::ios::in | std::ios::out | std::ios::trunc); #endif