Hello All,
I've only just started to develope some code in VB.net and i have very little experience in it and some of the "instructional" web pages are very confusing to my dyslexic mind.
The scenario is as follows: -
I am connected to a server via VPN, but the connection speed to the server is kind of erratic. The CAD software I use in my day job, is quite processor hungry/dependent and sometimes the CAD software will stop working as it processes work/commands. Sometimes the issue is not the CAD software, but the latency of the VPN connection (this is not at my end, but the server connection). When the CAD stops working, I start a command prompt window and ping the server and get something like the following.
I would like to do something similar in vb.net.
I have a user form with a button on it to ping the cad server and this works and I can get a single result.
This uses the following code (which I have borrowed from somewhere):
Private Sub OnePingCadSvr_Click(sender As Object, e As EventArgs) Handles OnePingCadSvr.Click
Dim host As String = "0.0.0.0"
Dim pingreq As Ping = New Ping()
Dim rep As PingReply = pingreq.Send(host)
Dim SingleRoundtripTime As Long
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)
PingHost.Text = "Reply From: " & rep.Address.ToString()
PingHost.Refresh()
PingRoundTrip.Text = "Round Trip Time: " & rep.RoundtripTime & "ms" ' & rep.Options.Ttl
PingRoundTrip.Refresh()
System.Threading.Thread.Sleep(1500)
End Sub
If I try to run this 4 times in a FOR loop, the round trip time is exactly the same time for each iteration of the loop i.e. If I get 27ms for the first iteration, it will be the same value for the remaining iterations, whereas manually repeating a single ping, 4 times, I get slightly different speeds (as I would expect) and more inline with the cmd ping.
It almost feels like I need to reset something before each iteration of the FOR loop starts, but I don’t have a clue.
I have tried using google and I've gone through lots of different web sites and not come up with a solution, this is mainly because I don't really understand the syntax
Can anyone help?
I also realise that my code is probably not the best, but I’m trying to learn as I go.
Thanks in advance, Steve