<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Async: Async::DnsLookup Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.2-20100208 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="namespaceAsync.html">Async</a>::<a class="el" href="classAsync_1_1DnsLookup.html">DnsLookup</a> </div> </div> <div class="contents"> <h1>Async::DnsLookup Class Reference</h1><!-- doxytag: class="Async::DnsLookup" --> <p>A class for performing asynchronous DNS lookups. <a href="#_details">More...</a></p> <p><code>#include <<a class="el" href="AsyncDnsLookup_8h_source.html">AsyncDnsLookup.h</a>></code></p> <p><a href="classAsync_1_1DnsLookup-members.html">List of all members.</a></p> <h2>Public Member Functions</h2> <ul> <li><a class="el" href="classAsync_1_1DnsLookup.html#a4cd8bdfd33a2dd3920722a929d7ef9b2">DnsLookup</a> (const std::string &label) <dl class="el"><dd class="mdescRight">Constructor. <a href="#a4cd8bdfd33a2dd3920722a929d7ef9b2"></a><br/></dl><li><a class="el" href="classAsync_1_1DnsLookup.html#a1a37a3467eb386864bb39d4a12003779">~DnsLookup</a> (void) <dl class="el"><dd class="mdescRight">Destructor. <a href="#a1a37a3467eb386864bb39d4a12003779"></a><br/></dl><li>const std::string & <a class="el" href="classAsync_1_1DnsLookup.html#a3f0db56e2659e247a3d2782ee870292e">label</a> (void) const <dl class="el"><dd class="mdescRight">Return the associated label. <a href="#a3f0db56e2659e247a3d2782ee870292e"></a><br/></dl><li>std::vector< <a class="el" href="classAsync_1_1IpAddress.html">IpAddress</a> > <a class="el" href="classAsync_1_1DnsLookup.html#a4ebe7a7c9f981e12fb2ac70f3f655938">addresses</a> (void) <dl class="el"><dd class="mdescRight">Return the addresses for the host in the query. <a href="#a4ebe7a7c9f981e12fb2ac70f3f655938"></a><br/></dl></ul> <h2>Public Attributes</h2> <ul> <li>SigC::Signal1< void, <a class="el" href="classAsync_1_1DnsLookup.html">DnsLookup</a> & > <a class="el" href="classAsync_1_1DnsLookup.html#a1459ef33fe23f1e8e64e301c68ccf4ce">resultsReady</a> <dl class="el"><dd class="mdescRight">A signal to indicate that the query has been completed. <a href="#a1459ef33fe23f1e8e64e301c68ccf4ce"></a><br/></dl></ul> <hr/><a name="_details"></a><h2>Detailed Description</h2> <p>A class for performing asynchronous DNS lookups. </p> <dl class="author"><dt><b>Author:</b></dt><dd>Tobias Blomberg </dd></dl> <dl class="date"><dt><b>Date:</b></dt><dd>2003-04-12</dd></dl> <p>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.</p> <div class="fragment"><pre class="fragment"><span class="preprocessor">#include <iostream></span> <span class="preprocessor">#include <<a class="code" href="AsyncCppApplication_8h.html" title="The core class for writing asyncronous cpp applications.">AsyncCppApplication.h</a>></span> <span class="preprocessor">#include <<a class="code" href="AsyncDnsLookup_8h.html" title="Contains a class for executing DNS queries.">AsyncDnsLookup.h</a>></span> <span class="keyword">using namespace </span>std; <span class="keyword">using namespace </span>Async; <span class="keyword">class </span>MyClass : <span class="keyword">public</span> SigC::Object { <span class="keyword">public</span>: MyClass(<span class="keywordtype">void</span>) { cout << <span class="stringliteral">"Starting query of www.ibm.com...\n"</span>; dns_lookup = <span class="keyword">new</span> <a class="code" href="classAsync_1_1DnsLookup.html#a4cd8bdfd33a2dd3920722a929d7ef9b2" title="Constructor.">DnsLookup</a>(<span class="stringliteral">"www.ibm.com"</span>); dns_lookup->resultsReady.connect(slot(*<span class="keyword">this</span>, &MyClass::onResultsReady)); } ~MyClass(<span class="keywordtype">void</span>) { <span class="keyword">delete</span> dns_lookup; } <span class="keywordtype">void</span> onResultsReady(<a class="code" href="classAsync_1_1DnsLookup.html#a4cd8bdfd33a2dd3920722a929d7ef9b2" title="Constructor.">DnsLookup</a>& dns) { cout << <span class="stringliteral">"Results received:\n"</span>; vector<IpAddress> <a class="code" href="classAsync_1_1DnsLookup.html#a4ebe7a7c9f981e12fb2ac70f3f655938" title="Return the addresses for the host in the query.">addresses</a> = dns.addresses(); vector<IpAddress>::iterator it; <span class="keywordflow">for</span> (it = addresses.begin(); it != addresses.end(); ++it) { cout << *it << endl; } <span class="keyword">delete</span> dns_lookup; dns_lookup = 0; <a class="code" href="classAsync_1_1Application.html#aa6d446d6b333e0a1e5cc1400c07aa898" title="Get the one and only application instance.">Application::app</a>().quit(); } <span class="keyword">private</span>: <a class="code" href="classAsync_1_1DnsLookup.html#a4cd8bdfd33a2dd3920722a929d7ef9b2" title="Constructor.">DnsLookup</a> *dns_lookup; }; <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv) { CppApplication app; MyClass dns; app.exec(); } </pre></div> <dl><dt><b>Examples: </b></dt><dd> <p><a class="el" href="AsyncDnsLookup__demo_8cpp-example.html#_a0">AsyncDnsLookup_demo.cpp</a>.</p> </dd> </dl> <p>Definition at line <a class="el" href="AsyncDnsLookup_8h_source.html#l00120">120</a> of file <a class="el" href="AsyncDnsLookup_8h_source.html">AsyncDnsLookup.h</a>.</p> <hr/><h2>Constructor & Destructor Documentation</h2> <a class="anchor" id="a4cd8bdfd33a2dd3920722a929d7ef9b2"></a><!-- doxytag: member="Async::DnsLookup::DnsLookup" ref="a4cd8bdfd33a2dd3920722a929d7ef9b2" args="(const std::string &label)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Async::DnsLookup::DnsLookup </td> <td>(</td> <td class="paramtype">const std::string & </td> <td class="paramname"> <em>label</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Constructor. </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>label</em> </td><td>The label (hostname) to lookup </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a1a37a3467eb386864bb39d4a12003779"></a><!-- doxytag: member="Async::DnsLookup::~DnsLookup" ref="a1a37a3467eb386864bb39d4a12003779" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Async::DnsLookup::~DnsLookup </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Destructor. </p> </div> </div> <hr/><h2>Member Function Documentation</h2> <a class="anchor" id="a4ebe7a7c9f981e12fb2ac70f3f655938"></a><!-- doxytag: member="Async::DnsLookup::addresses" ref="a4ebe7a7c9f981e12fb2ac70f3f655938" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">std::vector<<a class="el" href="classAsync_1_1IpAddress.html">IpAddress</a>> Async::DnsLookup::addresses </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Return the addresses for the host in the query. </p> <dl class="return"><dt><b>Returns:</b></dt><dd>Return a stl vector which contains all the addresses associated with the hostname in the query. </dd></dl> <dl class="pre"><dt><b>Precondition:</b></dt><dd>The result is not available before the resultsReay signal has been emitted</dd></dl> <p>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. </p> <dl><dt><b>Examples: </b></dt><dd><a class="el" href="AsyncDnsLookup__demo_8cpp-example.html#a1">AsyncDnsLookup_demo.cpp</a>.</dd> </dl> </div> </div> <a class="anchor" id="a3f0db56e2659e247a3d2782ee870292e"></a><!-- doxytag: member="Async::DnsLookup::label" ref="a3f0db56e2659e247a3d2782ee870292e" args="(void) const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const std::string& Async::DnsLookup::label </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td> const<code> [inline]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Return the associated label. </p> <dl class="return"><dt><b>Returns:</b></dt><dd>Returns the label associated with this DNS lookup </dd></dl> <p>Definition at line <a class="el" href="AsyncDnsLookup_8h_source.html#l00138">138</a> of file <a class="el" href="AsyncDnsLookup_8h_source.html">AsyncDnsLookup.h</a>.</p> </div> </div> <hr/><h2>Member Data Documentation</h2> <a class="anchor" id="a1459ef33fe23f1e8e64e301c68ccf4ce"></a><!-- doxytag: member="Async::DnsLookup::resultsReady" ref="a1459ef33fe23f1e8e64e301c68ccf4ce" args="" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">SigC::Signal1<void, <a class="el" href="classAsync_1_1DnsLookup.html">DnsLookup</a>&> <a class="el" href="classAsync_1_1DnsLookup.html#a1459ef33fe23f1e8e64e301c68ccf4ce">Async::DnsLookup::resultsReady</a></td> </tr> </table> </div> <div class="memdoc"> <p>A signal to indicate that the query has been completed. </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>dns</em> </td><td>A reference to the DNS object associated with the query </td></tr> </table> </dd> </dl> <p>Definition at line <a class="el" href="AsyncDnsLookup_8h_source.html#l00156">156</a> of file <a class="el" href="AsyncDnsLookup_8h_source.html">AsyncDnsLookup.h</a>.</p> </div> </div> <hr/>The documentation for this class was generated from the following file:<ul> <li><a class="el" href="AsyncDnsLookup_8h_source.html">AsyncDnsLookup.h</a></li> </ul> </div> <hr class="footer"/><address style="text-align: right;"><small>Generated by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.2-20100208 </small></address> </body> </html>