473,382 Members | 1,204 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,382 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 7247
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?
1
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.