根据其 IP 地址检查网络上的另一台设备是否处于活动状态 [英] Check if another device is alive on the network based on its IP-address

查看:62
本文介绍了根据其 IP 地址检查网络上的另一台设备是否处于活动状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个简单的 UWP IoT 应用程序,该应用程序将在 Raspberry Pi 上的 Windows 10 IoT Core 上运行.

I'm trying to write a simple UWP IoT App that is to run on Windows 10 IoT Core on a Raspberry Pi.

应用程序需要测试本地网络上当前是否有另一台设备处于活动状态.所有应用程序都知道其他设备的 IP 地址.

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.

我从其他 SO 问题中看到 Ping 不受支持,因为 ICMP 是 WinRT 不支持.我认为 UWP 也是如此?

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?

我想我可以创建一个套接字并尝试连接到例如端口 80,除非出现超时错误收到则表示该设备可用.然而,hack"似乎有点混乱,我不确定它是否足够可靠.

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.

关于某些 C# UWP 代码的任何其他想法,可用于根据设备的 ip 地址测试设备在本地网络上是否可用和活动?

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?

推荐答案

你说得对,UWP 仍然不支持 ICMP.但您可以使用它:https://github.com/christophwille/winrt-vasily (这有点像你想做的,但已经完成了)

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)

这篇关于根据其 IP 地址检查网络上的另一台设备是否处于活动状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆