473,320 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Internet connection detection

Hi,
probably the question have been asked many times, but I can't find the
answer anywhere. Is there a way to detect if an internet connection is
active? just like Internet explorers detect you are offline when you try to
open it when not connected (then asks if you want to connect or work
offline). I need to detect if there is an internet connection available.

And if possible too (for another project) detect if a network connection
still work other than ping the main server (like know if the network cable
is not connected or adapter disabled and this kind of stuff)

Thanks

ThunderMusic

Aug 29 '05 #1
9 7244
In article <#n**************@TK2MSFTNGP15.phx.gbl>, ThunderMusic wrote:
Hi,
probably the question have been asked many times, but I can't find the
answer anywhere. Is there a way to detect if an internet connection is
active? just like Internet explorers detect you are offline when you try to
open it when not connected (then asks if you want to connect or work
offline). I need to detect if there is an internet connection available.

And if possible too (for another project) detect if a network connection
still work other than ping the main server (like know if the network cable
is not connected or adapter disabled and this kind of stuff)

Thanks

ThunderMusic


http://vb.mvps.org/samples/project.asp?id=NetConnect

This is an example written in VB6 by Karl Peterson. Should be fairly
straight forward to convert to VB.NET.

--
Tom Shelton [MVP]
Aug 29 '05 #2
thanks, I'll give it a try.

"Tom Shelton" <to*@YOUKNOWTHEDRILLmtogden.com> a écrit dans le message de
news:uo**************@TK2MSFTNGP09.phx.gbl...
In article <#n**************@TK2MSFTNGP15.phx.gbl>, ThunderMusic wrote:
Hi,
probably the question have been asked many times, but I can't find the
answer anywhere. Is there a way to detect if an internet connection is
active? just like Internet explorers detect you are offline when you try to open it when not connected (then asks if you want to connect or work
offline). I need to detect if there is an internet connection available.

And if possible too (for another project) detect if a network connection
still work other than ping the main server (like know if the network cable is not connected or adapter disabled and this kind of stuff)

Thanks

ThunderMusic


http://vb.mvps.org/samples/project.asp?id=NetConnect

This is an example written in VB6 by Karl Peterson. Should be fairly
straight forward to convert to VB.NET.

--
Tom Shelton [MVP]

Aug 29 '05 #3
If you're developing a 2.0 app, then you can use
My.Computer.Network.Isavailable(). If you're using 1.1, then it's equivalent
is:
Imports System.Net.NetworkInformation
Public ReadOnly Property IsAvailable() As Boolean
Get
For Each NetInterface As NetworkInterface In _
NetworkInterface.GetAllNetworkInterfaces()
If NetInterface.Type <> InterfaceType.Loopback _
AndAlso NetInterface.Type <> InterfaceType.Tunnel _
AndAlso NetInterface.OperationalStatus = _
OperationalStatus.Up Then
Return True
End If
Next
Return False
End Get
End Property

Cathal
"ThunderMusic" <NO*******@sympatico.caSPAMATALL> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,
probably the question have been asked many times, but I can't find the
answer anywhere. Is there a way to detect if an internet connection is
active? just like Internet explorers detect you are offline when you try to open it when not connected (then asks if you want to connect or work
offline). I need to detect if there is an internet connection available.

And if possible too (for another project) detect if a network connection
still work other than ping the main server (like know if the network cable
is not connected or adapter disabled and this kind of stuff)

Thanks

ThunderMusic

Aug 30 '05 #4
ThunderMusic wrote:
Hi,
probably the question have been asked many times, but I can't find the
answer anywhere. Is there a way to detect if an internet connection is
active? just like Internet explorers detect you are offline when you try to
open it when not connected (then asks if you want to connect or work
offline). I need to detect if there is an internet connection available.

And if possible too (for another project) detect if a network connection
still work other than ping the main server (like know if the network cable
is not connected or adapter disabled and this kind of stuff)

Thanks

ThunderMusic


You can also use that code:

[DllImport("url.dll")]
public static extern bool InetIsOffline(int dwFlags);
public static bool IsOffline()
{
return InetIsOffline(0);
}
public static bool IsOnline()
{
return !InetIsOffline(0);
}

£ukasz
Aug 30 '05 #5
My VS 2003 cannot find the System.Net.NetworkInformation namespace. Do I
have to add a reference to something? and btw, it is not in the msdn
documentation.

thanks

"Cathal Connolly [VB MVP]" <cc*******@eg-consulting.com> a écrit dans le
message de news:eH**************@TK2MSFTNGP10.phx.gbl...
If you're developing a 2.0 app, then you can use
My.Computer.Network.Isavailable(). If you're using 1.1, then it's equivalent is:
Imports System.Net.NetworkInformation
Public ReadOnly Property IsAvailable() As Boolean
Get
For Each NetInterface As NetworkInterface In _
NetworkInterface.GetAllNetworkInterfaces()
If NetInterface.Type <> InterfaceType.Loopback _
AndAlso NetInterface.Type <> InterfaceType.Tunnel _
AndAlso NetInterface.OperationalStatus = _
OperationalStatus.Up Then
Return True
End If
Next
Return False
End Get
End Property

Cathal
"ThunderMusic" <NO*******@sympatico.caSPAMATALL> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,
probably the question have been asked many times, but I can't find the
answer anywhere. Is there a way to detect if an internet connection is
active? just like Internet explorers detect you are offline when you try

to
open it when not connected (then asks if you want to connect or work
offline). I need to detect if there is an internet connection available.

And if possible too (for another project) detect if a network connection
still work other than ping the main server (like know if the network cable is not connected or adapter disabled and this kind of stuff)

Thanks

ThunderMusic


Aug 30 '05 #6
ok, maybe something is missing because yesterday night I lost internet
connection and the way you provided me still detected my computer as
connected to the internet. Maybe there is some caching going on, but I don't
understand because the flag INTERNET_FLAG_NO_CACHE_WRITE is present... So Am
I missing something?

thanks for the information

ThunderMusic
"Tom Shelton" <to*@YOUKNOWTHEDRILLmtogden.com> a écrit dans le message de
news:uo**************@TK2MSFTNGP09.phx.gbl...
In article <#n**************@TK2MSFTNGP15.phx.gbl>, ThunderMusic wrote:
Hi,
probably the question have been asked many times, but I can't find the
answer anywhere. Is there a way to detect if an internet connection is
active? just like Internet explorers detect you are offline when you try to open it when not connected (then asks if you want to connect or work
offline). I need to detect if there is an internet connection available.

And if possible too (for another project) detect if a network connection
still work other than ping the main server (like know if the network cable is not connected or adapter disabled and this kind of stuff)

Thanks

ThunderMusic


http://vb.mvps.org/samples/project.asp?id=NetConnect

This is an example written in VB6 by Karl Peterson. Should be fairly
straight forward to convert to VB.NET.

--
Tom Shelton [MVP]

Aug 30 '05 #7
ok, with my searches, the System.Net.NetworkInformation namespace is in VS
2005... :(
"ThunderMusic" <NO*******@sympatico.caSPAMATALL> a écrit dans le message de
news:em***************@TK2MSFTNGP09.phx.gbl...
My VS 2003 cannot find the System.Net.NetworkInformation namespace. Do I
have to add a reference to something? and btw, it is not in the msdn
documentation.

thanks

"Cathal Connolly [VB MVP]" <cc*******@eg-consulting.com> a écrit dans le
message de news:eH**************@TK2MSFTNGP10.phx.gbl...
If you're developing a 2.0 app, then you can use
My.Computer.Network.Isavailable(). If you're using 1.1, then it's

equivalent
is:
Imports System.Net.NetworkInformation
Public ReadOnly Property IsAvailable() As Boolean
Get
For Each NetInterface As NetworkInterface In _
NetworkInterface.GetAllNetworkInterfaces()
If NetInterface.Type <> InterfaceType.Loopback _
AndAlso NetInterface.Type <> InterfaceType.Tunnel _
AndAlso NetInterface.OperationalStatus = _
OperationalStatus.Up Then
Return True
End If
Next
Return False
End Get
End Property

Cathal
"ThunderMusic" <NO*******@sympatico.caSPAMATALL> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,
probably the question have been asked many times, but I can't find the
answer anywhere. Is there a way to detect if an internet connection is
active? just like Internet explorers detect you are offline when you try
to
open it when not connected (then asks if you want to connect or work
offline). I need to detect if there is an internet connection
available.
And if possible too (for another project) detect if a network connection still work other than ping the main server (like know if the network

cable is not connected or adapter disabled and this kind of stuff)

Thanks

ThunderMusic



Aug 30 '05 #8
On Tue, 30 Aug 2005 12:07:53 -0400, ThunderMusic wrote:
My VS 2003 cannot find the System.Net.NetworkInformation namespace. Do I
have to add a reference to something? and btw, it is not in the msdn
documentation.

Cathal Connolly's reply *began* with these words:
"Cathal Connolly [VB MVP]" <cc*******@eg-consulting.com> a écrit dans le
message de news:eH**************@TK2MSFTNGP10.phx.gbl...
If you're developing a 2.0 app, then you can use


"developing a 2.0 app" means using the .NET 2.0 framework, which would
generally imply using one of the VS.NET 2005 tools. (Although a madman
could be doing it entirely with the commandline compilers.)
Aug 30 '05 #9
yes but she added something afterward :
If you're developing a 2.0 app, then you can use
My.Computer.Network.Isavailable(). If you're using 1.1, then it's equivalent is:
Imports System.Net.NetworkInformation
So if I'm using 2.0, use Me.Computer.Network.Isavailable and if I'm using
1.1, then go for it's equivalent System.Net.NetworkInformation, which does
not seems to be in 1.1 is there an error in the name of the namespace or
just just tought this namespace was available to 1.1?

thanks

"Ross Presser" <rp******@NOSPAMgmail.com.invalid> a écrit dans le message de
news:v2**************@rosspresser.dyndns.org... On Tue, 30 Aug 2005 12:07:53 -0400, ThunderMusic wrote:
My VS 2003 cannot find the System.Net.NetworkInformation namespace. Do I
have to add a reference to something? and btw, it is not in the msdn
documentation.


Cathal Connolly's reply *began* with these words:
"Cathal Connolly [VB MVP]" <cc*******@eg-consulting.com> a écrit dans le
message de news:eH**************@TK2MSFTNGP10.phx.gbl...
If you're developing a 2.0 app, then you can use


"developing a 2.0 app" means using the .NET 2.0 framework, which would
generally imply using one of the VS.NET 2005 tools. (Although a madman
could be doing it entirely with the commandline compilers.)

Aug 30 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Yurij Nykon | last post by:
Hi all. How can I detect the version of Flash-Plugin installed in Internet Explorer? In Netscape i can do this with following java script navigator.plugins.description But it doesn't works...
6
by: Tim Johnson | last post by:
Hello All: Using javascript to dynamically add row elements to a table. as in ..... row.setAttribute("bgcolor",rowColor); // or cell.setAttribute("bgcolor",rowColor); Using firefox or...
4
by: Peter Flynn | last post by:
I'm having trouble finding example code to detect the presence of an Internet connection. It doesn't seem to be a very frequently asked question, as all I need is the answer yes or no (is the user...
2
by: the6campbells | last post by:
Vendors such as ORACLE document how they support the server being configured to provide dead connection detection. I see no documentation in the IBM manuals or support site notes that suggest that...
56
by: Raphi | last post by:
Hi, I've been using an Access application I wrote for an office with the front-end stored on all computers and the back-end on one of them serving as an Access file server. Now we're moving...
9
by: ThunderMusic | last post by:
Hi, probably the question have been asked many times, but I can't find the answer anywhere. Is there a way to detect if an internet connection is active? just like Internet explorers detect you...
15
by: ezmiller | last post by:
Does anybody know how to use javascript to test whether or not an internet connection exists? Is this possible even?
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.