This problem that faced most of developers !
I know it's easy to ping an IP Address with VB 05
my.computer.network.ping (google.com)
That's quite easy and works well but now if you are thinking big, like the Ping command . You want extra options and results...
So that's it !
Dim pingSender as new Ping()
Dim options as new PingOptions()
' Use the default Ttl value which is 128,
' but change the fragmentation behavior.
options.DontFragment = true
' Create a buffer of 32 bytes of data to be transmitted.
Dim data as string = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
Dim buffer(data.Length) as byte = Encoding.ASCII.GetBytes (data)
Dim timeout as integer = 120
Dim reply as PingReply = pingSender.Send (args(0), timeout, buffer, options)
if reply.Status = IPStatus.Success then
Console.WriteLine ("Address: {0}", reply.Address.ToString ())
Console.WriteLine ("RoundTrip time: {0}", reply.RoundtripTime)
Console.WriteLine ("Time to live: {0}", reply.Options.Ttl)
Console.WriteLine ("Don't fragment: {0}", reply.Options.DontFragment)
Console.WriteLine ("Buffer size: {0}", reply.Buffer.Length)
end if
Hope it helps lot of you ! Experts hihihi ;)
0 comments:
Post a Comment