第一種

Dim host AsString="82.123.23.XX"' use any other machine nameDim pingreq As Ping =New Ping()Dim rep As PingReply = pingreq.Send(host )
Console.WriteLine("Pinging {0} [{1}]", host , rep.Address.ToString())
Console.WriteLine("Reply From {0} : time={1} TTL={2}", rep.Address.ToString(), rep.RoundtripTime, rep.Options.Ttl)

需要

Import

System.Net.NetworkInformation

 

 

第二種

 

PublicSharedFunction GetPingMs(ByRef hostNameOrAddress AsString)Dim ping AsNew System.Net.NetworkInformation.Ping
    Return ping.Send(hostNameOrAddress).RoundtripTime
EndFunction

GetPingMs("127.0.0.1")

GetPingMs("www.dreamincode.net")
 

原始來源

http://www.dreamincode.net/code/snippet1511.htm

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 dark99 的頭像
    dark99

    個人記事

    dark99 發表在 痞客邦 留言(0) 人氣()