JMDNS 不适用于 4G 连接?
我正在尝试使用 jmdns 发现一些移动设备。只要我有 wifi 或 3G 连接,这些设备就可以被发现。于是乎,我用了4G连接,就说没有检测到任何设备。
ConnectivityManager conMgr = (ConnectivityManager) getSystemService (Context.CONNECTIVITY_SERVICE);
if ( conMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED
|| conMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED ) {}
我是否需要设置另一个条件才能启用 4G 连接? 4G 和 3G 之间最显着的区别是什么?
I'm trying to discover some mobile devices using jmdns. As long as i have wifi or 3G connection, the devices are discoverable. Ever since, i used 4G connection, it said that no devices are detected.
ConnectivityManager conMgr = (ConnectivityManager) getSystemService (Context.CONNECTIVITY_SERVICE);
if ( conMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED
|| conMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED ) {}
Do I have to put another condition to enable 4G connection? what's the most significant differences between 4G and 3G programmatically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我很惊讶它能在 3g 上运行。
Bonjour/Zeroconf 使用 mDNS 来发现其他设备的 IP 地址。它使用多播 UDP 向其他人宣告自己。我很确定这在 3g 网络上不起作用,因为它们使用 NAT 将用户与每个网络分开其他并防止互联网上的设备连接到它们(入站连接 - 互联网到 3g 设备)。阅读这些人在 3g 上测试多播 UDP 的文章: http://sourceforge .net/projects/open-dis/forums/forum/683284/topic/4058262
更新
用于检测网络在当前的 4g 设备上,您应该检查
ConnectivityManager.TYPE_WIMAX
。I'm quite surprised it works on 3g.
Bonjour/Zeroconf uses mDNS to discover other devices IP addresses. It uses multicast UDP to announce itself to others. I'm quite sure this does not work on 3g networks as they use NAT to separate users from each other and to prevent devices on internet connecting to them (inbound connections - internet to 3g device). Reads this guys testing of multicast UDP on 3g: http://sourceforge.net/projects/open-dis/forums/forum/683284/topic/4058262
Update
For detecting the network on current 4g devices you should check the
ConnectivityManager.TYPE_WIMAX
.