Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2008

Tip: Looking for answers? Try searching our database.

Checking internet connection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
basulasz - 09 Jan 2008 18:06 GMT
I want to check internet connectivity within a program. For example I want
the program to ping microsoft.com and to determine that there is a connection
according to ping responses.

How can I do that?
Peter Duniho - 09 Jan 2008 18:35 GMT
> I want to check internet connectivity within a program. For example I  
> want
[quoted text clipped - 3 lines]
>
> How can I do that?

Did you look at the Ping class? (in System.Net.NetworkInformation)
basulasz - 09 Jan 2008 18:48 GMT
No. Actually I haven't known about anything about that class. I am new in
.net, and haven't used this namespace before

> > I want to check internet connectivity within a program. For example I  
> > want
[quoted text clipped - 5 lines]
>
> Did you look at the Ping class? (in System.Net.NetworkInformation)
Phil Wilson - 10 Jan 2008 21:01 GMT
If you want a general API, IsInternetConnected will do it:
http://msdn2.microsoft.com/en-us/library/aa366143(VS.85).aspx
but for a specific site you'd need another test, like ping.

What are you trying to do? For example a ping to a specific location will
tell you about a physical connection, but opening a browser window to it can
fail if IE has phishing or security blocking of that site.
Signature

Phil Wilson
[MVP Windows Installer]

>I want to check internet connectivity within a program. For example I want
> the program to ping microsoft.com and to determine that there is a
> connection
> according to ping responses.
>
> How can I do that?
basulasz - 10 Jan 2008 21:12 GMT
I have a Windows service application which uses a web service to send SMS
messages to cell phones, and it requires an available internet connection, so
i need to ping a specific location, and I think ping class in .NET will be
helpful for this purpose.

Thanks a lot...

> If you want a general API, IsInternetConnected will do it:
> http://msdn2.microsoft.com/en-us/library/aa366143(VS.85).aspx
[quoted text clipped - 9 lines]
> >
> > How can I do that?
Ravi Bhavnani - 11 Jan 2008 04:40 GMT
I hacked up this little helper class that will allow you to check if you're
connected to the internet without having to ping a specific site.  The
method you need to call is NetUtils.IsConnectedToInternet().

/// <summary>
/// A collection of network related methods.
/// </summary>
public class NetUtils
{

/////////////////////
// Imported functions
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState
(out int nDescription,
int nReserved);

/////////////
// Operations
/// <summary>
/// Checks if a connection to the internet exists.
/// </summary>
/// <returns>true if a connection to the internet exists.</returns>

public static bool IsConnectedToInternet()
{
int nDesc = 0;
if (!InternetGetConnectedState (out nDesc, 0))
return (false);
return (true);
}
}

Cheers,

/ravi

------------------------------------------------------------------------
>I want to check internet connectivity within a program. For example I want
> the program to ping microsoft.com and to determine that there is a
> connection
> according to ping responses.
>
> How can I do that?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.