Solved

Determining if a Computer is online

Posted on 2003-10-27
4
205 Views
Last Modified: 2010-04-16
What is the easiest way, in code, to determine if a computer is online? that is, if it has a working internet connection at runtime.

0
Comment
Question by:jjacksn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Expert Comment

by:jlach
ID: 9629744
Yeah, open a connection to say www.yahoo.com.. set a timeout, if a response is back within that timeout, your online
0
 
LVL 5

Author Comment

by:jjacksn
ID: 9630167
Yeah, I want to do something like that, but what is the easiest way to do that in code?
0
 

Accepted Solution

by:
ilúvatar earned 100 total points
ID: 9641870
Try this...


System.Net.HttpWebRequest wr = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("http://google.com/");

try
{
      System.Net.HttpWebResponse ws = (System.Net.HttpWebResponse)wr.GetResponse();
      MessageBox.Show( " ONLINE " );
}
catch
{
      MessageBox.Show( " OFFLINE " );
}
0
 
LVL 1

Expert Comment

by:jlach
ID: 9642223
iluvatar's got it...
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question