473,396 Members | 1,816 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,396 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

Nov 21 '05 #1
9 1474
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]
Nov 21 '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]

Nov 21 '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

Nov 21 '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
Nov 21 '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


Nov 21 '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]

Nov 21 '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



Nov 21 '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.)
Nov 21 '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.)

Nov 21 '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...
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...
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.