The TCP/IP stack contains a domain name full resolver service. Client
programs make DNS queries through the generic host name resolution interface
RHostResolver
, specifying protocol-specific behaviour through
argument values. This section contains notes on the particular usage of
RHostResolver
functions for DNS. It does not repeat the
information contained in the documentation for RHostResolver
, to
which you should always refer first.
RHostResolver
is defined in es_sock.h
. Types
and constants specific to TCP/IP that are used in RHostResolver
arguments are defined in in_sock.h
.
DNS access is initialised with RHostResolver::Open()
.
The argument values are:
|
When DNS is no longer needed, access should be closed using
RHostResolver::Close()
.
When a query is made, the protocol takes the following sequence of actions:
Searches the local HOSTS file, if it exists. This file should be
called hosts
and stored in the \private\10000882\
directory.
If no answer has been found, checks the DNS cache.
If no answer has been found, formulates and sends a query via a UDP socket to the DNS server. If there is no current connection, dial-up is invoked.
If an answer is found, it is added to the cache.
Note that cached entries are held indefinitely as long as the
Client's RHostResolver
object is open - even for TTL 0 records.
Therefore, if the client wishes to ensure only the most up to date records are
returned from its query, it should Open a fresh RHostResolver
for
each new query.
Note that the DNS server used is either negotiated by PPP in establishing a dial-up connection, or configured by the user in ISP settings.
Note that the
RHostResolver::GetByName()
/RHostResolver::GetByAddress()
can be called asynchronously so that the application can choose to do that
early in the program and the data will have arrived by the time it is needed
later on. See comment under Next Result below on using
Next
.
Use RHostResolver::GetByName()
to resolve a symbolic
name to an IP address. The arguments are as follows:
|
Use RHostResolver::
GetByAddress()
to
obtain an IP address from a symbolic name. The arguments are as follows:
|
The Next()
function is used to find further answers
after an initial GetByName()
or GetByAddress()
query.
For GetByName()
, the matching A record (IP address) is
returned first. Calls to Next()
return any further CNAME (alias)
or A records. CNAME records have the IP address set to 0 and the
EDnsAlias
flag set.
For GetByAddress()
, the first matching PTR record
(domain name) is returned first. Calls to Next()
return any
further PTR records.
Note that Next()
can be called synchronously because all
information is retrieved from a local buffer that was written by the initial
query.
RHostResolver::GetHostName()
and
RHostResolver::SetHostName()
get and set respectively the name of
the local host. Note that these functions simply get and set a local variable.