You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
335 lines
16 KiB
335 lines
16 KiB
13 years ago
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||
4 months ago
|
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/network/tqdns.cpp:1597 -->
|
||
13 years ago
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||
|
<title>TQDns Class</title>
|
||
|
<style type="text/css"><!--
|
||
|
fn { margin-left: 1cm; text-indent: -1cm; }
|
||
|
a:link { color: #004faf; text-decoration: none }
|
||
|
a:visited { color: #672967; text-decoration: none }
|
||
|
body { background: #ffffff; color: black; }
|
||
|
--></style>
|
||
|
</head>
|
||
|
<body>
|
||
|
|
||
|
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||
|
<tr bgcolor="#E5E5E5">
|
||
|
<td valign=center>
|
||
|
<a href="index.html">
|
||
|
<font color="#004faf">Home</font></a>
|
||
|
| <a href="classes.html">
|
||
|
<font color="#004faf">All Classes</font></a>
|
||
|
| <a href="mainclasses.html">
|
||
|
<font color="#004faf">Main Classes</font></a>
|
||
|
| <a href="annotated.html">
|
||
|
<font color="#004faf">Annotated</font></a>
|
||
|
| <a href="groups.html">
|
||
|
<font color="#004faf">Grouped Classes</font></a>
|
||
|
| <a href="functions.html">
|
||
|
<font color="#004faf">Functions</font></a>
|
||
|
</td>
|
||
|
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQDns Class Reference<br><small>[<a href="network.html">network module</a>]</small></h1>
|
||
|
|
||
|
<p>The TQDns class provides asynchronous DNS lookups.
|
||
|
<a href="#details">More...</a>
|
||
4 months ago
|
<p><tt>#include <<a href="tqdns-h.html">tqdns.h</a>></tt>
|
||
6 months ago
|
<p>Inherits <a href="tqobject.html">TQObject</a>.
|
||
4 months ago
|
<p><a href="tqdns-members.html">List of all member functions.</a>
|
||
13 years ago
|
<h2>Public Members</h2>
|
||
|
<ul>
|
||
|
<li class=fn>enum <a href="#RecordType-enum"><b>RecordType</b></a> { None, A, Aaaa, Mx, Srv, Cname, Ptr, Txt }</li>
|
||
|
<li class=fn><a href="#TQDns"><b>TQDns</b></a> ()</li>
|
||
|
<li class=fn><a href="#TQDns-2"><b>TQDns</b></a> ( const TQString & label, RecordType rr = A )</li>
|
||
|
<li class=fn><a href="#TQDns-3"><b>TQDns</b></a> ( const TQHostAddress & address, RecordType rr = Ptr )</li>
|
||
|
<li class=fn>virtual <a href="#~TQDns"><b>~TQDns</b></a> ()</li>
|
||
|
<li class=fn>virtual void <a href="#setLabel"><b>setLabel</b></a> ( const TQString & label )</li>
|
||
|
<li class=fn>virtual void <a href="#setLabel-2"><b>setLabel</b></a> ( const TQHostAddress & address )</li>
|
||
|
<li class=fn>TQString <a href="#label"><b>label</b></a> () const</li>
|
||
|
<li class=fn>virtual void <a href="#setRecordType"><b>setRecordType</b></a> ( RecordType rr = A )</li>
|
||
|
<li class=fn>RecordType <a href="#recordType"><b>recordType</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#isWorking"><b>isWorking</b></a> () const</li>
|
||
|
<li class=fn>TQValueList<TQHostAddress> <a href="#addresses"><b>addresses</b></a> () const</li>
|
||
|
<li class=fn>TQValueList<MailServer> <a href="#mailServers"><b>mailServers</b></a> () const</li>
|
||
|
<li class=fn>TQValueList<Server> <a href="#servers"><b>servers</b></a> () const</li>
|
||
|
<li class=fn>TQStringList <a href="#hostNames"><b>hostNames</b></a> () const</li>
|
||
|
<li class=fn>TQStringList <a href="#texts"><b>texts</b></a> () const</li>
|
||
|
<li class=fn>TQString <a href="#canonicalName"><b>canonicalName</b></a> () const</li>
|
||
|
<li class=fn>TQStringList <a href="#qualifiedNames"><b>qualifiedNames</b></a> () const</li>
|
||
|
</ul>
|
||
|
<h2>Signals</h2>
|
||
|
<ul>
|
||
|
<li class=fn>void <a href="#resultsReady"><b>resultsReady</b></a> ()</li>
|
||
|
</ul>
|
||
|
<hr><a name="details"></a><h2>Detailed Description</h2>
|
||
|
|
||
|
|
||
|
The TQDns class provides asynchronous DNS lookups.
|
||
|
|
||
|
<p>
|
||
|
|
||
|
<p> Both Windows and Unix provide synchronous DNS lookups; Windows
|
||
|
provides some asynchronous support too. At the time of writing
|
||
|
neither operating system provides asynchronous support for
|
||
|
anything other than hostname-to-address mapping.
|
||
|
<p> TQDns rectifies this shortcoming, by providing asynchronous caching
|
||
|
lookups for the record types that we expect modern GUI
|
||
|
applications to need in the near future.
|
||
|
<p> The class is <em>not</em> straightforward to use (although it is much
|
||
4 months ago
|
simpler than the native APIs); <a href="tqsocket.html">TQSocket</a> provides much easier to use
|
||
13 years ago
|
TCP connection facilities. The aim of TQDns is to provide a correct
|
||
|
and small API to the DNS and nothing more. (We use "correctness"
|
||
|
to mean that the DNS information is correctly cached, and
|
||
|
correctly timed out.)
|
||
|
<p> The API comprises a constructor, functions to set the DNS node
|
||
|
(the domain in DNS terminology) and record type (<a href="#setLabel">setLabel</a>() and
|
||
|
<a href="#setRecordType">setRecordType</a>()), the corresponding get functions, an <a href="#isWorking">isWorking</a>()
|
||
|
function to determine whether TQDns is working or reading, a
|
||
|
<a href="#resultsReady">resultsReady</a>() signal and query functions for the result.
|
||
|
<p> There is one query function for each RecordType, namely
|
||
|
<a href="#addresses">addresses</a>(), <a href="#mailServers">mailServers</a>(), <a href="#servers">servers</a>(), <a href="#hostNames">hostNames</a>() and <a href="#texts">texts</a>().
|
||
|
There are also two generic query functions: <a href="#canonicalName">canonicalName</a>()
|
||
|
returns the name you'll presumably end up using (the exact meaning
|
||
|
of this depends on the record type) and <a href="#qualifiedNames">qualifiedNames</a>() returns a
|
||
|
list of the fully qualified names <a href="#label">label</a>() maps to.
|
||
4 months ago
|
<p> <p>See also <a href="tqsocket.html">TQSocket</a> and <a href="io.html">Input/Output and Networking</a>.
|
||
13 years ago
|
|
||
|
<hr><h2>Member Type Documentation</h2>
|
||
|
<h3 class=fn><a name="RecordType-enum"></a>TQDns::RecordType</h3>
|
||
|
|
||
|
<p> This enum type defines the record types TQDns can handle. The DNS
|
||
|
provides many more; these are the ones we've judged to be in
|
||
|
current use, useful for GUI programs and important enough to
|
||
|
support right away:
|
||
|
<ul>
|
||
|
<li><tt>TQDns::None</tt> - No information. This exists only so that TQDns can
|
||
|
have a default.
|
||
|
<li><tt>TQDns::A</tt> - IPv4 addresses. By far the most common type.
|
||
|
<li><tt>TQDns::Aaaa</tt> - IPv6 addresses. So far mostly unused.
|
||
|
<li><tt>TQDns::Mx</tt> - Mail eXchanger names. Used for mail delivery.
|
||
|
<li><tt>TQDns::Srv</tt> - SeRVer names. Generic record type for finding
|
||
|
servers. So far mostly unused.
|
||
|
<li><tt>TQDns::Cname</tt> - Canonical names. Maps from nicknames to the true
|
||
|
name (the canonical name) for a host.
|
||
|
<li><tt>TQDns::Ptr</tt> - name PoinTeRs. Maps from IPv4 or IPv6 addresses to hostnames.
|
||
|
<li><tt>TQDns::Txt</tt> - arbitrary TeXT for domains.
|
||
|
</ul><p> We expect that some support for the
|
||
|
<a href="http://www.dns.net/dnsrd/rfc/rfc2535.html">RFC-2535</a>
|
||
|
extensions will be added in future versions.
|
||
|
|
||
|
<hr><h2>Member Function Documentation</h2>
|
||
|
<h3 class=fn><a name="TQDns"></a>TQDns::TQDns ()
|
||
|
</h3>
|
||
|
Constructs a DNS query object with invalid settings for both the
|
||
|
label and the search type.
|
||
|
|
||
4 months ago
|
<h3 class=fn><a name="TQDns-2"></a>TQDns::TQDns ( const <a href="tqstring.html">TQString</a> & label, <a href="tqdns.html#RecordType-enum">RecordType</a> rr = A )
|
||
13 years ago
|
</h3>
|
||
|
Constructs a DNS query object that will return record type <em>rr</em>
|
||
|
information about <em>label</em>.
|
||
|
<p> The DNS lookup is started the next time the application enters the
|
||
|
event loop. When the result is found the signal <a href="#resultsReady">resultsReady</a>() is
|
||
|
emitted.
|
||
|
<p> <em>rr</em> defaults to <a href="#RecordType-enum">A</a>, IPv4 addresses.
|
||
|
|
||
4 months ago
|
<h3 class=fn><a name="TQDns-3"></a>TQDns::TQDns ( const <a href="tqhostaddress.html">TQHostAddress</a> & address, <a href="tqdns.html#RecordType-enum">RecordType</a> rr = Ptr )
|
||
13 years ago
|
</h3>
|
||
|
Constructs a DNS query object that will return record type <em>rr</em>
|
||
|
information about host address <em>address</em>. The label is set to the
|
||
|
IN-ADDR.ARPA domain name. This is useful in combination with the
|
||
|
<a href="#RecordType-enum">Ptr</a> record type (e.g. if you want to look up a hostname for a
|
||
|
given address).
|
||
|
<p> The DNS lookup is started the next time the application enters the
|
||
|
event loop. When the result is found the signal <a href="#resultsReady">resultsReady</a>() is
|
||
|
emitted.
|
||
|
<p> <em>rr</em> defaults to <a href="#RecordType-enum">Ptr</a>, that maps addresses to hostnames.
|
||
|
|
||
|
<h3 class=fn><a name="~TQDns"></a>TQDns::~TQDns ()<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
Destroys the DNS query object and frees its allocated resources.
|
||
|
|
||
5 months ago
|
<h3 class=fn><a href="tqvaluelist.html">TQValueList</a><TQHostAddress> <a name="addresses"></a>TQDns::addresses () const
|
||
13 years ago
|
</h3>
|
||
|
Returns a list of the addresses for this name if this TQDns object
|
||
|
has a <a href="#recordType">recordType</a>() of <a href="#RecordType-enum">TQDns::A</a> or <a href="#RecordType-enum">TQDns::Aaaa</a> and the answer
|
||
|
is available; otherwise returns an empty list.
|
||
|
<p> As a special case, if <a href="#label">label</a>() is a valid numeric IP address, this
|
||
|
function returns that address.
|
||
|
<p> Note that if you want to iterate over the list, you should iterate
|
||
|
over a copy, e.g.
|
||
|
<pre>
|
||
5 months ago
|
<a href="tqvaluelist.html">TQValueList</a><TQHostAddress> list = myDns.addresses();
|
||
|
TQValueList<TQHostAddress>::Iterator it = list.<a href="tqvaluelist.html#begin">begin</a>();
|
||
|
while( it != list.<a href="tqvaluelist.html#end">end</a>() ) {
|
||
13 years ago
|
myProcessing( *it );
|
||
|
++it;
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<p>
|
||
5 months ago
|
<h3 class=fn><a href="tqstring.html">TQString</a> <a name="canonicalName"></a>TQDns::canonicalName () const
|
||
13 years ago
|
</h3>
|
||
|
Returns the canonical name for this DNS node. (This works
|
||
|
regardless of what <a href="#recordType">recordType</a>() is set to.)
|
||
|
<p> If the canonical name isn't known, this function returns a null
|
||
|
string.
|
||
|
<p> The canonical name of a DNS node is its full name, or the full
|
||
|
name of the target of its CNAME. For example, if l.trolltech.com
|
||
|
is a CNAME to lillian.troll.no, and the search path for TQDns is
|
||
|
"trolltech.com", then the canonical name for all of "lillian",
|
||
|
"l", "lillian.troll.no." and "l.trolltech.com" is
|
||
|
"lillian.troll.no.".
|
||
|
|
||
5 months ago
|
<h3 class=fn><a href="tqstringlist.html">TQStringList</a> <a name="hostNames"></a>TQDns::hostNames () const
|
||
13 years ago
|
</h3>
|
||
|
Returns a list of host names if the record type is <a href="#RecordType-enum">Ptr</a>.
|
||
|
<p> Note that if you want to iterate over the list, you should iterate
|
||
|
over a copy, e.g.
|
||
|
<pre>
|
||
5 months ago
|
<a href="tqstringlist.html">TQStringList</a> list = myDns.hostNames();
|
||
5 months ago
|
TQStringList::Iterator it = list.<a href="tqvaluelist.html#begin">begin</a>();
|
||
|
while( it != list.<a href="tqvaluelist.html#end">end</a>() ) {
|
||
13 years ago
|
myProcessing( *it );
|
||
|
++it;
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<p>
|
||
|
<h3 class=fn>bool <a name="isWorking"></a>TQDns::isWorking () const
|
||
|
</h3>
|
||
|
Returns TRUE if TQDns is doing a lookup for this object (i.e. if it
|
||
|
does not already have the necessary information); otherwise
|
||
|
returns FALSE.
|
||
|
<p> TQDns emits the <a href="#resultsReady">resultsReady</a>() signal when the status changes to FALSE.
|
||
|
|
||
|
<p>Example: <a href="mail-example.html#x705">network/mail/smtp.cpp</a>.
|
||
5 months ago
|
<h3 class=fn><a href="tqstring.html">TQString</a> <a name="label"></a>TQDns::label () const
|
||
13 years ago
|
</h3>
|
||
|
|
||
|
<p> Returns the domain name for which this object returns information.
|
||
|
<p> <p>See also <a href="#setLabel">setLabel</a>().
|
||
|
|
||
5 months ago
|
<h3 class=fn><a href="tqvaluelist.html">TQValueList</a><MailServer> <a name="mailServers"></a>TQDns::mailServers () const
|
||
13 years ago
|
</h3>
|
||
|
Returns a list of mail servers if the record type is <a href="#RecordType-enum">Mx</a>. The
|
||
|
class <tt>TQDns::MailServer</tt> contains the following public variables:
|
||
|
<ul>
|
||
5 months ago
|
<li> <a href="tqstring.html">TQString</a> TQDns::MailServer::name
|
||
13 years ago
|
<li> TQ_UINT16 TQDns::MailServer::priority
|
||
13 years ago
|
</ul>
|
||
|
<p> Note that if you want to iterate over the list, you should iterate
|
||
|
over a copy, e.g.
|
||
|
<pre>
|
||
5 months ago
|
<a href="tqvaluelist.html">TQValueList</a><TQDns::MailServer> list = myDns.mailServers();
|
||
|
TQValueList<TQDns::MailServer>::Iterator it = list.<a href="tqvaluelist.html#begin">begin</a>();
|
||
|
while( it != list.<a href="tqvaluelist.html#end">end</a>() ) {
|
||
13 years ago
|
myProcessing( *it );
|
||
|
++it;
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<p>
|
||
|
<p>Example: <a href="mail-example.html#x706">network/mail/smtp.cpp</a>.
|
||
5 months ago
|
<h3 class=fn><a href="tqstringlist.html">TQStringList</a> <a name="qualifiedNames"></a>TQDns::qualifiedNames () const
|
||
13 years ago
|
</h3>
|
||
|
|
||
|
<p> Returns a list of the fully qualified names <a href="#label">label</a>() maps to.
|
||
|
<p> Note that if you want to iterate over the list, you should iterate
|
||
|
over a copy, e.g.
|
||
|
<pre>
|
||
5 months ago
|
<a href="tqstringlist.html">TQStringList</a> list = myDns.qualifiedNames();
|
||
5 months ago
|
TQStringList::Iterator it = list.<a href="tqvaluelist.html#begin">begin</a>();
|
||
|
while( it != list.<a href="tqvaluelist.html#end">end</a>() ) {
|
||
13 years ago
|
myProcessing( *it );
|
||
|
++it;
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<p>
|
||
4 months ago
|
<h3 class=fn><a href="tqdns.html#RecordType-enum">RecordType</a> <a name="recordType"></a>TQDns::recordType () const
|
||
13 years ago
|
</h3>
|
||
|
|
||
|
<p> Returns the record type of this DNS query object.
|
||
|
<p> <p>See also <a href="#setRecordType">setRecordType</a>() and <a href="#RecordType-enum">RecordType</a>.
|
||
|
|
||
|
<h3 class=fn>void <a name="resultsReady"></a>TQDns::resultsReady ()<tt> [signal]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> This signal is emitted when results are available for one of the
|
||
|
<a href="#qualifiedNames">qualifiedNames</a>().
|
||
|
|
||
|
<p>Example: <a href="mail-example.html#x707">network/mail/smtp.cpp</a>.
|
||
5 months ago
|
<h3 class=fn><a href="tqvaluelist.html">TQValueList</a><Server> <a name="servers"></a>TQDns::servers () const
|
||
13 years ago
|
</h3>
|
||
|
Returns a list of servers if the record type is <a href="#RecordType-enum">Srv</a>. The class
|
||
|
<tt>TQDns::Server</tt> contains the following public variables:
|
||
|
<ul>
|
||
5 months ago
|
<li> <a href="tqstring.html">TQString</a> TQDns::Server::name
|
||
13 years ago
|
<li> TQ_UINT16 TQDns::Server::priority
|
||
|
<li> TQ_UINT16 TQDns::Server::weight
|
||
|
<li> TQ_UINT16 TQDns::Server::port
|
||
13 years ago
|
</ul>
|
||
|
<p> Note that if you want to iterate over the list, you should iterate
|
||
|
over a copy, e.g.
|
||
|
<pre>
|
||
5 months ago
|
<a href="tqvaluelist.html">TQValueList</a><TQDns::Server> list = myDns.servers();
|
||
|
TQValueList<TQDns::Server>::Iterator it = list.<a href="tqvaluelist.html#begin">begin</a>();
|
||
|
while( it != list.<a href="tqvaluelist.html#end">end</a>() ) {
|
||
13 years ago
|
myProcessing( *it );
|
||
|
++it;
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
|
||
5 months ago
|
<h3 class=fn>void <a name="setLabel"></a>TQDns::setLabel ( const <a href="tqstring.html">TQString</a> & label )<tt> [virtual]</tt>
|
||
13 years ago
|
</h3>
|
||
|
Sets this DNS query object to query for information about <em>label</em>.
|
||
|
<p> This does not change the <a href="#recordType">recordType</a>(), but its <a href="#isWorking">isWorking</a>() status
|
||
|
will probably change as a result.
|
||
|
<p> The DNS lookup is started the next time the application enters the
|
||
|
event loop. When the result is found the signal <a href="#resultsReady">resultsReady</a>() is
|
||
|
emitted.
|
||
|
|
||
4 months ago
|
<h3 class=fn>void <a name="setLabel-2"></a>TQDns::setLabel ( const <a href="tqhostaddress.html">TQHostAddress</a> & address )<tt> [virtual]</tt>
|
||
13 years ago
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> Sets this DNS query object to query for information about the host
|
||
|
address <em>address</em>. The label is set to the IN-ADDR.ARPA domain
|
||
|
name. This is useful in combination with the <a href="#RecordType-enum">Ptr</a> record type
|
||
|
(e.g. if you want to look up a hostname for a given address).
|
||
|
|
||
4 months ago
|
<h3 class=fn>void <a name="setRecordType"></a>TQDns::setRecordType ( <a href="tqdns.html#RecordType-enum">RecordType</a> rr = A )<tt> [virtual]</tt>
|
||
13 years ago
|
</h3>
|
||
|
Sets this object to query for record type <em>rr</em> records.
|
||
|
<p> The DNS lookup is started the next time the application enters the
|
||
|
event loop. When the result is found the signal <a href="#resultsReady">resultsReady</a>() is
|
||
|
emitted.
|
||
|
<p> <p>See also <a href="#RecordType-enum">RecordType</a>.
|
||
|
|
||
5 months ago
|
<h3 class=fn><a href="tqstringlist.html">TQStringList</a> <a name="texts"></a>TQDns::texts () const
|
||
13 years ago
|
</h3>
|
||
|
Returns a list of texts if the record type is <a href="#RecordType-enum">Txt</a>.
|
||
|
<p> Note that if you want to iterate over the list, you should iterate
|
||
|
over a copy, e.g.
|
||
|
<pre>
|
||
5 months ago
|
<a href="tqstringlist.html">TQStringList</a> list = myDns.texts();
|
||
5 months ago
|
TQStringList::Iterator it = list.<a href="tqvaluelist.html#begin">begin</a>();
|
||
|
while( it != list.<a href="tqvaluelist.html#end">end</a>() ) {
|
||
13 years ago
|
myProcessing( *it );
|
||
|
++it;
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
<!-- eof -->
|
||
|
<hr><p>
|
||
|
This file is part of the <a href="index.html">TQt toolkit</a>.
|
||
|
Copyright © 1995-2007
|
||
|
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
||
|
<table width=100% cellspacing=0 border=0><tr>
|
||
|
<td>Copyright © 2007
|
||
|
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
||
|
<td align=right><div align=right>TQt 3.3.8</div>
|
||
|
</table></div></address></body>
|
||
|
</html>
|