DnsLookup

DnsLookup 用於將主機名稱解析為 IP 位址。 該功能主要用於連線到伺服器時在不知道其 IP 的情況下使用。

語法

DnsLookup(主機名稱)

結果

字串(IP 位址)。

範例

簡單的 dns 尋找和反向尋找:

Function Main

Dim SocketObject As Object

Dim ServerName As String

Dim IP As String

Dim ResolvedName As String

'歸位字元和換行字元

cr = Chr(13) + Chr(10)

ServerName = "whois.networksolutions.com"

echo("正在解析"+cr)

Socket.SetTimeout 5000,5000

ip = socket.DnsLookup(ServerName)

echo(ServerName + " resolves to the IP Address:"+cr )

echo(ip +cr)

ResolvedName = Socket.ReverseDnsLookup(ip)

echo(cr)

echo("IP 位址 "+ip+ " 解析至 "+cr)

echo(ResolvedName+cr)

End Function