Solved

Determining if a Computer is online

Posted on 2003-10-27
4
203 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
  • 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

786 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