Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ping class not available in UWP

I think this is a simple problem. I have an IP address and I want to ping it and get its duration. However, in UWP there is no Ping class.

How do I ping an IP without this class? Should I connect to a specific port instead?

like image 618
Numan Ali Avatar asked May 18 '16 13:05

Numan Ali


2 Answers

Add the System.Net.Ping NuGet package to your project

like image 155
Vitaly Avatar answered Oct 14 '22 01:10

Vitaly


try to ping Port 80. Normally thats the port you have to use if you are pinging a website.

try this:

            HostName host = new HostName("www.google.com");
            var eps = await DatagramSocket.GetEndpointPairsAsync(host , "80");
            if(eps.Count >= 1)
            {
                return true;
            }
            else
            {
                return false;
            }
like image 45
rickrvo Avatar answered Oct 13 '22 23:10

rickrvo