ITK Programmer's Guide


 

Table of contents | Intro | General | TCP Low Level | TCP High Level | UDP | DNS | PPP
Encoding/Decoding | Internet Config | Goodies | Cryptography & SSL | Appendix

 

Chapter 6 : DNS Routines

   

   

Chapter contents:


About this chapter...

This chapter describes DNS related routines that can be used to convert host names into IP addresses and vice-versa.


ITK_Addr2Name

Syntax:

hostName := ITK_Addr2Name (hostaddr;options)


Description:

Translates an IP address (stored as a Long Integer) into its corresponding "network name" (a string).

ITK_Addr2Name accepts an options flag to specify the desired result format.

Params:

In/Out

Parameter

Type

   

Example or note

->

 

hostAddr

 

Longint

 

IP address to translate

As returned for example by ITK_Name2Addr

->

options

Longint

   

Options values:

0 = return the full address if possible otherwise return a "dotted address".

1 = return only full text addresses obtained from a DNS or an empty string if no answer could be received from the DNS.

2 = always return a "dotted address".

<-

hostName

String

Host name or empty string (depending on the option value).

   


Example:

$addr := ITK_Name2Addr("www.internet-toolkit.com")
$name := ITK_Addr2Name($addr) ` should return something like "server.cquest.org"
$dotted := ITK_Addr2Name($addr;2) ` should return "194.2.244.11"
Back to top


ITK_Name2Addr

Syntax:

hostAddr := ITK_Name2Addr (hostName;option)


Description:

Translates an address into its corresponding IP address, i.e.: server1.jca.fr -> 194.2.244.11
If the original address is empty, ITK_Name2Addr returns the local IP address.

An option flag can allow you to use DNS load balancing. This flag can be used to specify which address you want if more than one address is returned for the given host name by the DNS.


Params:

In/Out

Parameter

Type

   

Example or note

->

 

hostName

 

String

 

host name to resolve

   

->

option

Text

pathname of the file to send

Option values for DNS load balancing:

  • 0 or 1, returns the first IP address returned by the DNS (or 0 if the address couldn't be resolved)
  • 2, returns the second address
  • 3, returns the third address
  • 4, returns the fourth address
  • -1, returns one of the resolved addresses chosen randomly
<-

hostAddr

Longint

   

0 = no address returned, couldn't resolve hostName.


Example:

$addr := ITK_Name2Addr("www.internet-toolkit.com")
 
$addr := ITK_Name2Addr("www.internet-toolkit.com";-1) ` use DNS load balancing (random choice)
 
$addr := ITK_Name2Addr("www.internet-toolkit.com";2) ` get 2nd Address (may return 0)
Back to top


CQ/24-Jun-98