zoukankan      html  css  js  c++  java
  • 【android】【研究】HTC不能接收组播

    It looks like some (most?) HTC phones running Android, such as my HTC EVO, are not capable of receiving multicast or broadcast datagram packets over the Wi-Fi network. This means that apps which rely on such communication will fail, often with no indication of the problem. From the app's perspective, no obvious error is happening — it can only assume that no other devices on the network are transmitting such datagrams. Multicast communication is becoming increasingly common as a technique for devices to discover each other on a network, and the absence of this capability represents serious breakage that leaves apps crippled. Examples of resources an app might use multicast to discover are:

    • iTunes music libraries
    • entertainment center components such as Roku and AppleTV
    • network shares
    • other devices running the same app, to set up multiplayer games

    Without a functioning multicast capability, these apps either don't work, or require the user to manually configure the IP addresses of the other devices.

    There is speculation that HTC's restriction is an attempt to save power and prolong battery life — it takes energy to process a network's many multicast and broadcast packets, many of which are useless to the device and its applications. However, Android already has a facility for allowing prudent use of multicast when needed. Applications acquire a WifiManager.MulticastLock for the duration of their multicast needs, which causes the Wi-Fi chip to stop filtering multicast packets until the app releases the lock. Thus, multicast processing in the software TCP/IP stack only happens when it's really needed.

    This is a bit frustrating, as I'm currently tinkering with some multicast code. Some people have been able to fix the problem by rooting their phones and replacing the /system/bin/wpa_supplicant binary with a stock version. This doesn't seem to help on my EVO. To add to the frustration, it can be difficult to test multicast in the Android emulator. I finally had some success in testing multicast code by running android-x86 in a VirtualBox virtual machine, with the network configured for bridging.

    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.

    作者:风倾清凌
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
  • 相关阅读:
    Handlerbars基础笔记
    each()和eq()
    可编辑表格(Editable Table)
    垂直居中vertical-align
    CSS属性的私有前缀
    CSS进阶知识
    CSS预处理器们
    CSS3之伪元素选择器和伪类选择器
    CSS基础复习
    Plan
  • 原文地址:https://www.cnblogs.com/Amandaliu/p/2505954.html
Copyright © 2011-2022 走看看