[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Need to track whether several IP addresses are pingable

Posted on 2007-08-04
7
Medium Priority
?
172 Views
Last Modified: 2013-12-17
I need to write a little program which tracks if several websites are up or down, and would use ping to find out.

I would need to use ping from within C#, then be able to analyze the results.

Can someone advise on howto issure the ping then how to parse the results to find if it worked?
0
Comment
Question by:newbieweb
7 Comments
 

Author Comment

by:newbieweb
ID: 19631025
please also advise on the number of ping failures needed before my program can conclude the site is in fact down.
0
 
LVL 29

Assisted Solution

by:Gautham Janardhan
Gautham Janardhan earned 600 total points
ID: 19631117
You could perform a request and check whether you get anything back.
public static bool Ping ( string IP)
{
WebRequest Req= WebRequest.Create(IP);
try
{
Req.GetResponse();
return true;
}
catch
{
}
return false;
}
0
 
LVL 19

Accepted Solution

by:
drichards earned 1400 total points
ID: 19631123
Easiest way is (assuming .NET 2.0) to use the Ping class:

http://msdn2.microsoft.com/en-us/library/system.net.networkinformation.ping.aspx

You can send sunchronously or asynchronously and you need to inspect the PingReply to determine the status of the remote host.  You also need to catch the potential exceptions that can be thrown.
0
Independent Software Vendors: 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!

 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 19631128
0
 
LVL 19

Expert Comment

by:drichards
ID: 19631146
>> or in .Net 3.0
That's the same thing.  It was added in 2.0.
0
 
LVL 11

Expert Comment

by:anyoneis
ID: 19631178
0
 
LVL 19

Expert Comment

by:drichards
ID: 19631207
Unless you really know what you are doing it is best not to play with the options.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month19 days, 18 hours left to enroll

872 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