Resolve IP Address and Host Name

If you are making the chat (TCP/IP) program, just I tape the strating on the previous I found this step helpful for you so that your user can determine the Name of the IP Address that they are sending to !
Vice versa, the IP address of the host ;)
This is the code :
First imports "System.Net.Dns"
Now learn how to get the IP address of the Local Computer !
Dim hostAddresses() As Net.IPAddress
Dim ipList As String = ""
Dim Address As Net.IPAddress

hostAddresses = Net.Dns.GetHostAddresses(Net.Dns.GetHostName())
For Each Address In hostAddresses
ipList &= vbCrLf & Address.ToString()
Next Address
MsgBox(Net.Dns.GetHostName() & vbNewLine & ipList)
and then get the host name of an ip :
or Resolve the IP address of a host
Dim hostEntry As Net.IPHostEntry
Dim scanAddress As Net.IPAddress
Dim hostAddresses As String = ""
hostEntry = Net.Dns.GetHostEntry("vectra")
For Each scanAddress In hostEntry.AddressList
Next scanAddress

DNS expert will know why resolving IP Address is more complex :)


Post a Comment