DnsLookup

Overview

The DnsLookup class provides static helper methods for resolving host names to IP addresses.

Location

Class Methods


ResolveAll

ResolveAll returns an array with all IP addresses for the given host name. In load balancing scenarios, several IP addresses can be provided in the DNS servers for the same host name. It's usually up to the application to decide which IP address to use. If the host name could not be resolved, an empty array is returned. To retrieve one specific IP address, you will usually use ResolveFirst or ResolveAll.

 

class method ResolveAll(hostname: String): array of IPAddress

 

static IPAddress[] ResolveAll(String hostname)

 

Shared Function ResolveAll(hostname As String) As IPAddress()

Parameters:

  • hostname:

ResolveFirst

Resolves the given host name and returns the first IP address that matches it. If the host could not be resolved, a DnsResolveException is thrown.

 

class method ResolveFirst(hostname: String): IPAddress

 

static IPAddress ResolveFirst(String hostname)

 

Shared Function ResolveFirst(hostname As String) As IPAddress

Parameters:

  • hostname:

ResolveRandom

Resolves the given host name and - if multiple IP Addresses are avaiable - returns a random IP address from the list. This can be used in load balancing scenarios to hit a random of several available hosts. If the host could not be resolved, a DnsResolveException is thrown.

 

class method ResolveRandom(hostname: String): IPAddress

 

static IPAddress ResolveRandom(String hostname)

 

Shared Function ResolveRandom(hostname As String) As IPAddress

Parameters:

  • hostname:

ReverseResolve

Obtains the host name for a given IP address via reverse-dns, if possible.

 

class method ReverseResolve(address: IPAddress): String

 

static String ReverseResolve(IPAddress address)

 

Shared Function ReverseResolve(address As IPAddress) As String

Parameters:

  • address:

TryStringAsIPAddress

 

class method TryStringAsIPAddress(hostname: String): IPAddress

 

static IPAddress TryStringAsIPAddress(String hostname)

 

Shared Function TryStringAsIPAddress(hostname As String) As IPAddress

Parameters:

  • hostname: