DnsLookup

DnsLookup 用于将主机名解析为 IP 地址。 该功能主要用于在连接服务器时在不知道其 IP 的情况下使用。

语法

DnsLookup(hostname)

返回结果

字符串(IP 地址)。

示例

非常简单的 dns 查找和反向查找:

函数 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("Resolving"+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 Address "+ip+ " resolves to "+cr)

echo(ResolvedName+cr)

End 函数