void tracker_manager::send(aux::listen_socket_handle const& sock , udp::endpoint const& ep , span<char const> p , error_code& ec, udp_send_flags_t const flags) { TORRENT_ASSERT(is_single_thread()); m_send_fun(sock, ep, p, ec, flags); }
bool dht_tracker::send_packet(entry& e, udp::endpoint const& addr) { static char const version_str[] = {'L', 'T' , LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR }; e["v"] = std::string(version_str, version_str + 4); m_send_buf.clear(); bencode(std::back_inserter(m_send_buf), e); // update the quota. We won't prevent the packet to be sent if we exceed // the quota, we'll just (potentially) block the next incoming request. m_send_quota -= int(m_send_buf.size()); error_code ec; m_send_fun(addr, m_send_buf, ec, 0); if (ec) { m_counters.inc_stats_counter(counters::dht_messages_out_dropped); #ifndef TORRENT_DISABLE_LOGGING m_log->log_packet(dht_logger::outgoing_message, m_send_buf, addr); #endif return false; } m_counters.inc_stats_counter(counters::dht_bytes_out, m_send_buf.size()); // account for IP and UDP overhead m_counters.inc_stats_counter(counters::sent_ip_overhead_bytes , addr.address().is_v6() ? 48 : 28); m_counters.inc_stats_counter(counters::dht_messages_out); #ifndef TORRENT_DISABLE_LOGGING m_log->log_packet(dht_logger::outgoing_message, m_send_buf, addr); #endif return true; }