Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Net.NetworkInformation
- Imports System.Net
- Module Module1
- Sub Main()
- Dim p As New Ping()
- Dim ttl As Integer = 0
- Dim host As IPAddress
- Dim response As PingReply = p.Send("www.google.com")
- Dim target As IPAddress = response.Address
- Dim buffer(1) As Byte
- Dim watch As New Stopwatch()
- Do
- Dim options As PingOptions
- ttl += 1
- options = New PingOptions(ttl, True)
- Console.Write("{0,3} ", ttl)
- For i As Integer = 1 To 3
- watch.Restart()
- response = p.Send(target.Address, 5000, buffer, options)
- watch.Stop()
- host = response.Address
- If response.Status = IPStatus.TimedOut Then
- Console.Write(" * ")
- Else
- Console.Write("{0,3} ms ", watch.ElapsedMilliseconds)
- End If
- Next
- If response.Status = IPStatus.TimedOut Then
- Console.WriteLine("Request timed out.")
- Else
- Console.WriteLine("{0}", host.ToString())
- End If
- Loop Until target.Equals(host)
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement