473,480 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 7256
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
10000
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
9796
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
2790
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
2444
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
5899
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
1478
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
27748
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
7080
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...
1
6735
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6895
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4770
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4476
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2992
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2977
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1296
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
176
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.