User`s guide
132
K
A
DAK
KwikNet Low Level Services
DNS Queries
The DNS client will always start a new DNS name lookup by querying the primary DNS
server first. If no primary DNS server exists, the query will fail. If the query to the
primary DNS server fails, the DNS client will then query the secondary DNS server, if
one exists.
The results of each DNS query are kept in a name cache maintained by the DNS client.
Each cached entry includes one or more of the IP addresses provided by the DNS server
which resolved the name. The total number of cached names is determined by you when
you configure your
KwikNet Library.
Once the
KwikNet TCP/IP Stack has been initialized, your application can call Treck
function tfDnsGetHostByName() to make a DNS name query. You can also call Treck
function
tfDnsGetHostAddr() to find the DNS name for a specific IP address, a form of
reverse DNS lookup.
In a multitasking system, any task making such a query must be of lower priority than the
KwikNet Task. If the name is already in the DNS client's name cache, you will
immediately be given the first available IP address from the list in that name's cache
entry. If a new query must be made and there is no room in the name cache, the oldest
cached name will be purged so that your request can be granted. The KwikNet DNS Client
will then initiate the query.
The Treck functions return with an error code indicating the success or failure of the
operation. If you have configured the DNS client to operate in non-blocking mode, the
Treck functions may return with error code TM_EWOULDBLOCK indicating that your query is
underway. In this case, you must repeat the query periodically to await the final result of
the query, indicated by a return value other than TM_EWOULDBLOCK.
If you have configured the DNS client to operate in blocking mode, the Treck functions
will only return when the query is complete. The return value will indicate the success or
failure of the operation.
Get Host By Name
Many networking systems provide the function
gethostbyname() which finds the IP
address for a host with a specific domain name. The prototype for this function indicates
that the function is inherently non-reentrant. For this reason,
KwikNet provides the
alternate, reentrant Treck function tfDnsGetHostByName() better suited for use in
multitasking systems.