Ping class 在 UWP 中不可用
Ping class not available in UWP
我认为这是一个简单的问题。我有一个 IP 地址,我想对它执行 ping 操作并获取它的持续时间。但是,在 UWP 中没有 Ping
class.
没有这个 class 如何 ping 一个 IP?我应该改为连接到特定端口吗?
尝试 ping 端口 80。通常这是您在 ping 网站时必须使用的端口。
试试这个:
HostName host = new HostName("www.google.com");
var eps = await DatagramSocket.GetEndpointPairsAsync(host , "80");
if(eps.Count >= 1)
{
return true;
}
else
{
return false;
}
将 System.Net.Ping NuGet 包添加到您的项目
我认为这是一个简单的问题。我有一个 IP 地址,我想对它执行 ping 操作并获取它的持续时间。但是,在 UWP 中没有 Ping
class.
没有这个 class 如何 ping 一个 IP?我应该改为连接到特定端口吗?
尝试 ping 端口 80。通常这是您在 ping 网站时必须使用的端口。
试试这个:
HostName host = new HostName("www.google.com");
var eps = await DatagramSocket.GetEndpointPairsAsync(host , "80");
if(eps.Count >= 1)
{
return true;
}
else
{
return false;
}
将 System.Net.Ping NuGet 包添加到您的项目