ndn::dns Namespace Reference

Classes

struct  AnyAddress
 
struct  Ipv4Only
 
struct  Ipv6Only
 

Typedefs

using AddressSelector = std::function< bool(const boost::asio::ip::address &)>
 
using ErrorCallback = std::function< void(const std::string &reason)>
 
using SuccessCallback = std::function< void(const boost::asio::ip::address &address)>
 

Functions

void asyncResolve (const std::string &host, const SuccessCallback &onSuccess, const ErrorCallback &onError, boost::asio::io_context &ioCtx, const AddressSelector &addressSelector=AnyAddress(), time::nanoseconds timeout=4_s)
 Asynchronously resolve host. More...
 

Typedef Documentation

◆ AddressSelector

using ndn::dns::AddressSelector = typedef std::function<bool(const boost::asio::ip::address&)>

Definition at line 35 of file dns.hpp.

◆ ErrorCallback

using ndn::dns::ErrorCallback = typedef std::function<void(const std::string& reason)>

Definition at line 65 of file dns.hpp.

◆ SuccessCallback

using ndn::dns::SuccessCallback = typedef std::function<void(const boost::asio::ip::address& address)>

Definition at line 64 of file dns.hpp.

Function Documentation

◆ asyncResolve()

void ndn::dns::asyncResolve ( const std::string &  host,
const SuccessCallback onSuccess,
const ErrorCallback onError,
boost::asio::io_context &  ioCtx,
const AddressSelector addressSelector = AnyAddress(),
time::nanoseconds  timeout = 4_s 
)

Asynchronously resolve host.

If an address selector predicate is specified, then each resolved IP address is checked against the predicate.

Available address selector predicates:

  • dns::AnyAddress()
  • dns::Ipv4Address()
  • dns::Ipv6Address()
Warning
Even after the DNS resolution has timed out, it's possible that ioCtx keeps running and onSuccess is invoked at a later time. This could cause segmentation fault if onSuccess is deallocated. To stop the io_context, explicitly invoke ioCtx.stop().

Definition at line 116 of file dns.cpp.