Dns.GetHostByAddress creates an IPHostEntry instance from the specified IPAddress. : Dns « Network Remote « VB.Net






Dns.GetHostByAddress creates an IPHostEntry instance from the specified IPAddress.

 
Imports System.IO
Imports System.Net
Imports System.Text

public class MainClass
   Shared Sub Main()
    Dim IpAddressString As String = ""
    Try
        Dim hostIPAddress As IPAddress = IPAddress.Parse(IpAddressString)
        Dim hostInfo As IPHostEntry = Dns.GetHostByAddress(hostIPAddress)
        Dim address As IPAddress() = hostInfo.AddressList
        Dim [alias] As [String]() = hostInfo.Aliases

        Console.WriteLine(hostInfo.HostName)
        Dim index As Integer
        For index = 0 To [alias].Length - 1
            Console.WriteLine([alias](index))
        Next index
        For index = 0 To address.Length - 1
            Console.WriteLine(address(index))
        Next index
    Catch e As Exception
        Console.WriteLine("Exception caught!!!")
        Console.WriteLine(("Source : " + e.Source))
        Console.WriteLine(("Message : " + e.Message))
    End Try
   End Sub
End Class

   
  








Related examples in the same category

1.Uri.Authority Property gets the Domain Name System (DNS) host name or IP address and the port number for a server.
2.Uri.CheckHostName Method tells whether the specified host name is a valid DNS name.
3.Uri.DnsSafeHost Property gets an unescaped host name that is safe to use for DNS resolution.
4.Dns Class provides simple domain name resolution functionality.
5.Dns.GetHostByName gets the DNS information for the specified DNS host name.
6.Dns.GetHostEntry resolves a host name or IP address to an IPHostEntry instance.
7.Dns.GetHostName gets the host name of the local computer.
8.Dns.Resolve resolves a DNS host name or IP address to an IPHostEntry instance.