Android 2.2 上的组播

发布于 2024-09-18 00:27:03 字数 1438 浏览 5 评论 0原文

有没有人在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我是有多爱你 2024-09-25 00:27:03

为了(粗​​鲁地)回答我自己的问题,在 http 上提供了更多信息另一个人的://code.google.com/p/android/issues/detail?id=2917#c48。正如他们所说,对于后代,这是[电子邮件受保护]的答案...

“我花了相当多的时间
在我的机器上使用 JmDNS 调试 mDNS 问题
Evo 和 HTC Hero (CDMA)。我发现了什么
似乎有一个过滤器
放置在 Broadcom 无线驱动程序中
在 Evo 上(因为我得到了
HTC Desire 用户的类似报告
- 使用相同的芯片组,大概也是该手机)。过滤器,由
默认情况下,阻止任何非单播或
网络广播流量,包括
多播。显然这个理论是
这是一个省电工具。

问题似乎是
Evo 上的 wpa_supplicant 没有
支持删除这些过滤器
你得到一个多播锁。 (检查
获得后立即记录输出
锁定,你就会明白我的意思)。
不幸的是发生的事情是
硬件供应商已经分散
多播支持....:("

所以...看来这是一个设备问题,而不是编码问题。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...

"I've spent quite a bit of time
debugging mDNS issues with JmDNS on my
Evo and HTC Hero (CDMA). What I found
is there appears to be a filter in
place in the broadcom wireless driver
on the Evo (and since I'm getting a
similiar reprt from an HTC Desire user
- with the same chipset, presumably that handset as well). The filter, by
default, blocks any non-unicast or
network broadcast traffic, including
multicast. Apparently the theory was
it's a battery saver.

The problem appears to be the
wpa_supplicant on the Evo does not
support removing those filters when
you get a MulticastLock. (Check the
log output right after you get the
lock and you'll see what I mean).
Unfortunately what has happened is the
hardware vendors have fragmented
multicast support.... :("

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...

南风几经秋 2024-09-25 00:27:03

我对此进行了一些研究,我相信这是 Android 的一个普遍问题,并在 Android 2.3.7 中或前后得到了修复。

这有点太轶事了,但这是我测试的:

  • HTC Desire,2.2,stock:失败
  • HTC Desire,2.3.7,CyanogenMod:成功
  • Motorola Milestone,2.1-update1:​​失败
  • HTC Desire S,2.3.3:失败
  • Acer Iconia A501 ,3.2.1:成功
  • 三星某事,2.3.3:失败
  • HTC Legend,2.2我认为:失败

当我说“失败”时,事实上他们都能够向“成功”设备发送多播消息,但从未收到任何东西除了他们自己的消息外,其他人都回来了——正如 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:

  • HTC Desire, 2.2, stock: fail
  • HTC Desire, 2.3.7, CyanogenMod: success
  • Motorola Milestone, 2.1-update1: fail
  • HTC Desire S, 2.3.3: fail
  • Acer Iconia A501, 3.2.1: success
  • Samsung something, 2.3.3: fail
  • HTC Legend, 2.2 I think: fail

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.

偏闹i 2024-09-25 00:27:03

我认为另一个原因是你的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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文