可以通过
DatagramSocket.GetEndpointPairsAsync ,获取远程IP地址。
样例代码如下。
private async void SampleMethod()
{
try
{
Windows.Networking.HostName strHost = new Windows.Networking.HostName("www.google.com");
IReadOnlyList<Windows.Networking.EndpointPair> endPointPairList = await Windows.Networking.Sockets.DatagramSocket.GetEndpointPairsAsync(strHost, "0");
foreach(Windows.Networking.EndpointPair endPoint in endPointPairList)
{
Debug.WriteLine("EndPoint is " + endPoint.RemoteHostName.RawName);
}
}
catch (Exception oEx)
{
Debug.WriteLine("Exception occurred: " + oEx.Message);
}
}
Robin [MSFT]
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.