Skip to content

Net_DNS

Stephane Carrez edited this page May 1, 2017 · 2 revisions

DNS Network utilities

DNS Client

The DNS client is used to make a DNS resolution and resolve a hostname to get an IP address (RFC 1035). The client implementation is based on the UDP client sockets and it uses a random UDP port to receive the DNS response.

Initialization

The DNS client is represented by the Query tagged type. An instance must be declared for each hostname that must be resolved.

Client : Net.DNS.Query;

Hostname resolution

The hostname resolution is started by calling the Resolve operation on the query object. That operation needs an access to the network interface to be able to send the DNS query packet. It returns a status code that indicates whether the packet was sent or not.

Client.Resolve (Ifnet'Access, "www.google.com", Status);

The DNS resolution is asynchronous. The Resolve operation does not wait for the response. The Get_Status operation can be used to look at the progress of the DNS query. The value PENDING indicates that a request was sent but no response was received yet. The value NOERROR indicates that the DNS resolution was successful.

Once the Get_Status operation returns the NOERROR value, the IPv4 address can be obtained by using the Get_Ip function.

IP : Net.Ip_Addr := Client.Get_Ip;

Generated by Dynamo from net-dns.ads

Clone this wiki locally