A class for performing asynchronous DNS lookups. More...
#include <AsyncDnsLookup.h>
A class for performing asynchronous DNS lookups.
Use this class to make DNS lookups. Right now it only supports looking up hostnames to find out what IP-addresses it maps to. An example usage can be seen below.
#include <iostream> #include <AsyncCppApplication.h> #include <AsyncDnsLookup.h> using namespace std; using namespace Async; class MyClass : public SigC::Object { public: MyClass(void) { cout << "Starting query of www.ibm.com...\n"; dns_lookup = new DnsLookup("www.ibm.com"); dns_lookup->resultsReady.connect(slot(*this, &MyClass::onResultsReady)); } ~MyClass(void) { delete dns_lookup; } void onResultsReady(DnsLookup& dns) { cout << "Results received:\n"; vector<IpAddress> addresses = dns.addresses(); vector<IpAddress>::iterator it; for (it = addresses.begin(); it != addresses.end(); ++it) { cout << *it << endl; } delete dns_lookup; dns_lookup = 0; Application::app().quit(); } private: DnsLookup *dns_lookup; }; int main(int argc, char **argv) { CppApplication app; MyClass dns; app.exec(); }
Definition at line 120 of file AsyncDnsLookup.h.
Async::DnsLookup::DnsLookup | ( | const std::string & | label | ) |
Constructor.
label | The label (hostname) to lookup |
Async::DnsLookup::~DnsLookup | ( | void | ) |
Destructor.
std::vector<IpAddress> Async::DnsLookup::addresses | ( | void | ) |
Return the addresses for the host in the query.
Use this function to retrieve all the IP-addresses associated with the hostname in the query. If the list is empty, the query has failed.
const std::string& Async::DnsLookup::label | ( | void | ) | const [inline] |
Return the associated label.
Definition at line 138 of file AsyncDnsLookup.h.
SigC::Signal1<void, DnsLookup&> Async::DnsLookup::resultsReady |
A signal to indicate that the query has been completed.
dns | A reference to the DNS object associated with the query |
Definition at line 156 of file AsyncDnsLookup.h.