Get Aliases from IPHostEntry : IPHostEntry « Socket Network « VB.Net Tutorial






Imports System.Net
Imports System.Net.Sockets


Public Class Tester
    Public Shared Sub Main
        Dim localHostName As String
        Dim localHostEntry As IPHostEntry
        Dim aliasList As String()
        Dim addrList As IPAddress()
    
        Dim i As Integer
        Dim strTemp As String
    
        Try
          localHostName = Dns.GetHostName
    
          localHostEntry = Dns.GetHostByName(localHostName)
    
          Console.WriteLine(localHostEntry.HostName)
    
          aliasList = localHostEntry.Aliases
    
          For i = 0 To aliasList.Length - 1
            Console.WriteLine(aliasList(i).ToString)
          Next
          
          addrList = localHostEntry.AddressList
    
          For i = 0 To addrList.Length - 1
            Console.WriteLine(addrList(i).ToString)
          Next
        Catch ex As SocketException
          Console.WriteLine(ex.StackTrace.ToString)
        End Try

    End Sub
End Class
java2s
192.168.1.101








22.6.IPHostEntry
22.6.1.Get Address List from IPHostEntry
22.6.2.Get Host By Address
22.6.3.Get Host By Name
22.6.4.Get Aliases from IPHostEntry