-
October 19th, 2015, 10:59 AM
#1
Why am I getting a TIMEOUT error?
When I run this app, it is suppose to ping each of those websites 4 times and save the results in a .csv file. But I keep getting either an exception handler error or the timeout error. What am I doing wrong? Please help me.
Code:
using System;
using System.Collection.Generic;
using System.IO;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using Threading.Teask;
namespace PingApp
{
class Program
{
static void Main(string[] args)
{
List<string> lstWebSites = new List<string>();
lstWebSites.Add("www.yahoo.com");
lstWebSites.Add("www.att.com");
lstWebSites.Add("www.verizon");
string filename = @"PingLog.csv";
{
using (var writer = new StreamWriter(filename, true))
{
foreach(string website in lstWebSites)
{
writer.WriteLine(website);
try
{
Ping myPing = new Ping();
PingReply reply = myPing.Send(website, 1000);
if (reply != null)
{
Console.WriteLine("{0}, {1}", reply.Address, reply.RoundtripTime);
}
}
catch
{
Console.WriteLine.("ERROR: You have some TIMEOUT issue");
}
}
}
}
}
}
}
-
October 19th, 2015, 02:58 PM
#2
Re: Why am I getting a TIMEOUT error?
Try to ping those addresses from the command-line.
I bet your ISP won't allow it or your corporate network blocks it.
To verify that ping local machines on your network.
Now the Exceptions may actually be other bugs you have introduced, but the timeouts
most likely are due to above mentioned reasons.
ahoodin
To keep the plot moving, that's why.
-
October 20th, 2015, 12:52 PM
#3
Re: Why am I getting a TIMEOUT error?
How do you know you have a timeout error since you are using an empty catch block? Maybe you have another error?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|