Reputation: 501
I am facing this exception "Impossible to send packets" when i am pinging www.google.com in my windows mobile app code (.netcf c#). But, pinging with localhost(127.0.0.1) gives the success result.
How to get resolve from this problem?
Here is my code..
public bool PingTest()
{
int packet=32;
IPHostEntry hostEnt = Dns.GetHostEntry("www.google.com");
IPAddress ip = hostEnt.AddressList[0];
PingOptions options = new PingOptions();
options.Ttl = 128;
options.DontFragment = false;
//Debug.WriteLine("Ip address: " + ip.Address);
Byte[] pkt= new Byte[packet];
Ping ping = new Ping();
try
{
//const string adr = "216.58.197.78";
PingReply pingReply = ping.Send(ip, pkt, 1000, options);
if (pingReply.Status == IPStatus.Success)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
Debug.WriteLine("The UnHandled Exception is: " + ex.Message);
return false;
}
}
Upvotes: 0
Views: 144