问题
I'm trying to write a simple UWP IoT App that is to run on Windows 10 IoT Core on a Raspberry Pi.
The App need to test if another device is currently alive on the local network. All the Apps knows about this other device is its ip address.
I see from other SO questions that Ping is not supporten because ICMP is not supported on WinRT. I assume this also the case on UWP?
I guess I could create a socket and try an connect to for example port 80 and unless a time-out error is received then that means the device is available. However that "hack" seems a bit messy and I'm not sure that it would be solid enough to rely on.
Any other ideas for some C# UWP code that can be used for testing that a device is available and alive on a local network based on its ip address?
回答1:
You are correct, ICMP is still not supported on UWP. But you could use this instead: https://github.com/christophwille/winrt-vasily (it's kind-of what you wanted to do, but already done)
来源:https://stackoverflow.com/questions/33319301/check-if-another-device-is-alive-on-the-network-based-on-its-ip-address