.NET Programming
--
Questions
--
Followers
Top Experts
If My.Computer.Network.Ping("
The above line returns an 'Internal Error' and doesn't work for some reason. It worked the first time I used it (when I was online) - when I unplugged my network cable and re-ran it I got errors - the errors persisted after reconnecting.
Is there any other way to check if the PC is online?
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
When you removed the cable and put it back and it stopped working, did your internet browser and or e-mail also stop working?
Is it also possible that you may have plugged it into the wrong connector?
You can also try the Ping class which give you more control of sending pigs out.
Ping class namespace, System.Net.NetworkInformat
System.Net.NetworkInformat
fernando
http://msdn2.microsoft.com/en-us/library/system.net.networkinformation.ping_members.aspx
No - I'm 100% familiar with the back of my PC - built it myself
I'll try the new statement - hopefully it works.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
The Ping item only has 'Equals' and 'RefernceEquals' items - doesn't have 'Send()'
This time everything seemed to work - however I got that error in the following situation:
-Unplugged network cable - waited a few seconds
-Ran program - goes through the following code:
If My.Computer.Network.IsAvai
If My.Computer.Network.Ping("
'All good
Else
If My.Computer.Network.Ping("
'Problem with my site
Else
'User is likely offline
End if
Endif
Else
'User offline
End if
The second Ping (EE.com) gave me the error

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
''''' make ping here
End If






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Now I have something like this:
--------------------------
On Error Resume Next
If My.Computer.Network.IsAvai
Dim ip As Net.IPHostEntry = Net.Dns.GetHostEntry("ryzz
If UBound(ip.AddressList) > -1 Then
If My.Computer.Network.Ping(i
''''OK
' Server is available
Else
''''' OFFLINE
' No network connection
MsgBox("It appears that you are still offline. Please check your Internet connection and try again later.", MsgBoxStyle.Information, "")
End If
Else
''''' INVALID HOST OR YOUR PROVIDER DNS CAN´T RESOLVE THE HOST
' Server is not responding
If My.Computer.Network.Ping("
MsgBox("Cannot connect to ryzza007.googlepages.com at the moment. Please try again later.", MsgBoxStyle.Information, "Server Unavailble")
Else
' No network connection
MsgBox("It appears that you are still offline. Please check your Internet connection and try again later.", MsgBoxStyle.Information, "VGEE")
End If
End If
Else
'''' PRIMARY NETWORK IS UNAVIABLE.
' No network connection
MsgBox("It appears that you are still offline. Please check your Internet connection and try again later.", MsgBoxStyle.Information, "VGEE")
End If
--------------------------
You may notice that the second ping isn't resolving the IP address before pinging. I probaly could adapt the above code to change this but am not sure if the line of code mentioning the array that holds the first IP Address will need to be changed for the second time or not? If you could let me know which code to use and where that would be fantastic.
Good to see you starting to answer questions, telefonia - keep up the good work :o)
I have an error on line the array because if exist some error you the app crash.
Copy this code:
--------------------
If My.Computer.Network.IsAvai
Dim IP As Net.IPHostEntry
Try
IP = Net.Dns.GetHostEntry("www.google.com")
Dim ping As New Net.NetworkInformation.Pin
Try
Dim result As Net.NetworkInformation.Pin
Select Case result.Status
Case Net.NetworkInformation.IPS
MsgBox("Success")
''''' You can get the AVERAGE time ping result. and you can determine if is good time for you app.
Dim average As Long = result.RoundtripTime
MsgBox("Average Time: " & average)
Case Else
''''' ERROR PING.
MsgBox(result.Status.ToStr
End Select
Catch ex As Net.NetworkInformation.Pin
MsgBox(ex.Message)
End Try
Catch ex As Net.Sockets.SocketExceptio
Dim codeerror As Net.Sockets.SocketError
codeerror = ex.ErrorCode
Select Case codeerror
Case Is = Net.Sockets.SocketError.Ho
'''''''''' Message for invalid host.
Case Else
'''''''''' Other errors.
MsgBox(codeerror.ToString)
End Select
End Try
Else
'''''' NO NETWORKS CONNECTION.
End If
Some customer is using a Satelital connection and have higth delay.
Other problem is somes host have firewall and block the icmp command in this case you can add a select case: Net.NetworkInformation.IPS
You can see the enu for all case: Select Case result.Status

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
It's not exectly life-or-death if it doesn't work for some extreme cases such as those you mentioned above - I just wanted to make sure it would work in all usual cases - and not display an 'Unhandled Exception' error every time someone started my application. Your most recent suggestions might be a little over-the-top for me (no fault of yours of course) so I'll stick with what I have currently (it works for me so far which is good).
The final part to this question is as follows:
On the first DNS resolve and ping - I have these lines of code:
-----------------
Dim ip As Net.IPHostEntry = Net.Dns.GetHostEntry("ryzz
If UBound(ip.AddressList) > -1 Then
If My.Computer.Network.Ping(i
-----------------
For my 2nd ping - which is nested in an If statement - can I use this code exactly or will it need minor refinements:
------------------
Dim ip As Net.IPHostEntry = Net.Dns.GetHostEntry("https://www.experts-exchange.com") 'Not using google.com - as it is related to the 1st site
If UBound(ip.AddressList) > -1 Then
If My.Computer.Network.Ping(i
------------------
And I'll also raise the points to 500 to help you get your Premium Services a little sooner :o)
If you alway check a fix site "your site" is more easy because you know that exist :),
So, your resume lines is correct.:)






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
.NET Programming
--
Questions
--
Followers
Top Experts
The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.