Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Determining if a Computer is online

Posted on 2003-10-27
4
Medium Priority
?
210 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 400 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

636 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