[vb]代码库
Imports System
Imports System.Net
Module Module1
Sub Main()
Dim strMachineName As String
'得到主机名
strMachineName = Dns.GetHostName()
Console.WriteLine("Host Name: " + strMachineName)
'通过名字得到主机
Dim ipHost As IPHostEntry
ipHost = Dns.GetHostByName(strMachineName)
'你可以得到网络上任何站点的DNS数据信息。
'语法如下:
'ipHost = Dns.GetHostByName("xml.sz.luohuedu.net")
Console.WriteLine("Host Aliases: " + ipHost.Aliases.Length.ToString())
'以数组的形式返回相关主机的地址信息
Dim ipAddr() As IPAddress = ipHost.AddressList
Dim count As Integer
'Enumerate the IP Addresses
For count = 0 To ipAddr.GetUpperBound(0)
Console.Write("IP 地址 {0}:{1} ", count, _
ipAddr(count).ToString)
Next
End Sub
End Module