diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index 8db836096..e1ecdf581 100755 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -530,6 +530,8 @@ namespace libtorrent if (has_requester()) requester().m_tracker_address = target_address; m_socket.reset(new stream_socket(m_name_lookup.io_service())); + m_socket->open(target_address.protocol()); + m_socket->bind(tcp::endpoint(bind_interface(), 0)); m_socket->async_connect(target_address, bind(&http_tracker_connection::connected, self(), _1)); } catch (std::exception& e) diff --git a/src/udp_tracker_connection.cpp b/src/udp_tracker_connection.cpp index c284e1b14..6e7becb5b 100755 --- a/src/udp_tracker_connection.cpp +++ b/src/udp_tracker_connection.cpp @@ -92,7 +92,6 @@ namespace libtorrent , m_settings(stn) , m_attempts(0) { - m_socket.reset(new datagram_socket(m_strand.io_service())); udp::resolver::query q(hostname, boost::lexical_cast(port)); m_name_lookup.async_resolve(q , m_strand.wrap(boost::bind( @@ -144,6 +143,9 @@ namespace libtorrent if (has_requester()) requester().m_tracker_address = tcp::endpoint(target_address.address(), target_address.port()); m_target = target_address; + m_socket.reset(new datagram_socket(m_name_lookup.io_service())); + m_socket->open(target_address.protocol()); + m_socket->bind(udp::endpoint(bind_interface(), 0)); m_socket->connect(target_address); send_udp_connect(); }