Android 2.2 上的组播
有没有人在 Android 2.2 上使用 Multicast,特别是用于 Bonjour 服务检测的 JmDNS。有很多问题& Android 1.5->2.0 时间范围内的答案(包括 stackOverflow 上的答案)表明不同程度的成功,以及 bug 跟踪器中的一个 bug,表明它已在 2.2 中修复并关闭(http://code.google.com/p/android/issues/detail?id=2323) 。我已经尝试过“TuneControl”源代码,但它在 ~1.5 上工作并且尚未更新,并且在 2.2 上对我不起作用。
所以,问题... 1) 有没有人见过 2.2 上的多播工作,特别是 JmDNS,特别是用于 Bonjour 服务检测?
2)代码中需要什么才能使其工作?
我正在使用适当的权限:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
我获取多播锁:
WifiManager wifi = (WifiManager)getSystemService( Context.WIFI_SERVICE );
if(wifi != null)
{
MulticastLock mcLock = wifi.createMulticastLock("mylock");
mcLock.acquire();
...
然后尝试启动 jmDNS 来查找服务器:
mdns = JmDNS.create(addr, HOSTNAME);
jmdns.addServiceListener(TOUCH_ABLE_TYPE, listener);
jmdns.addServiceListener(DACP_TYPE, listener);
...
侦听器永远看不到任何服务。我已经使用 Wireshark 验证了请求数据包已发送,并且服务器已响应,但 jmDNS 库中的套接字侦听器代码从未看到响应数据包。
那么...我错过了什么吗?这仍然是一个错误吗?有没有人得到这样的东西甚至远程工作???
Has anyone gotten Multicast to work on Android 2.2, specifically JmDNS for Bonjour service detection. There are many questions & answers from the Android 1.5->2.0 timeframe, including on stackOverflow, that indicate varying levels of success, and a bug in the bug tracker that indicate it was fixed, and closed, for 2.2 (http://code.google.com/p/android/issues/detail?id=2323) . I've tried the "TuneControl" source code, but that worked on ~1.5 and has not been updated, and does not work for me on 2.2.
So, the questions...
1) Has anyone seen multicast work on 2.2, specifically JmDNS, and specifically for Bonjour service detection?
2) What is necessary in code to make this work?
I'm using the appropriate permissions:
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
I acquire the multicast lock:
WifiManager wifi = (WifiManager)getSystemService( Context.WIFI_SERVICE );
if(wifi != null)
{
MulticastLock mcLock = wifi.createMulticastLock("mylock");
mcLock.acquire();
...
And then try to start jmDNS to look for servers:
mdns = JmDNS.create(addr, HOSTNAME);
jmdns.addServiceListener(TOUCH_ABLE_TYPE, listener);
jmdns.addServiceListener(DACP_TYPE, listener);
...
The listener never sees any services. I've verified using Wireshark that the request packets are sent, and that the server responds, but the response packet are never seen by the socket listener code in the jmDNS library.
So... am I missing something? Is this still a bug? Has ANYONE gotten anything even remotely like this to work???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为了(粗鲁地)回答我自己的问题,在 http 上提供了更多信息另一个人的://code.google.com/p/android/issues/detail?id=2917#c48。正如他们所说,对于后代,这是[电子邮件受保护]的答案...
所以...看来这是一个设备问题,而不是编码问题。D'oh。:(如果我有机会在另一台设备上进行测试...
To (rudely) answer my own question, more information was provided at http://code.google.com/p/android/issues/detail?id=2917#c48 by another person. For posterity, as they say, here is [email protected]'s answer...
So... it appears this is a device problem more than a coding problem. D'oh. :( If I get an opportunity to test on another device...
我对此进行了一些研究,我相信这是 Android 的一个普遍问题,并在 Android 2.3.7 中或前后得到了修复。
这有点太轶事了,但这是我测试的:
当我说“失败”时,事实上他们都能够向“成功”设备发送多播消息,但从未收到任何东西除了他们自己的消息外,其他人都回来了——正如 jldupont 所描述的那样。
请注意,多播 IM 应用 Kouchat 仅适用于适用于 2.3.7 及以上版本,尽管它可以编译早至 2.1,这进一步证实了这一理论。
I've been doing a bit of research into this, and I believe it is a problem with Android in general, and fixed in or around Android 2.3.7.
It's a bit too anecdotal, but here's what I tested:
When I say 'fail', in fact they were all able to send multicast messages to the 'success' devices, but never receive anything back except their own messages - as jldupont describes.
Note that the multicast IM app Kouchat is only available for 2.3.7 onwards, even though it can be made to compile for as far back as 2.1, which gives further credence to this theory.
我认为另一个原因是你的AP不支持。
其他:计算机与 Android 发送/接收
您的计算机必须仅使用 WIFI,最好关闭所有其他网络
I think the other reason is your AP does not support.
Other:Computer send/recieve to/from Android
your computer must only use WIFI,Best off all other network