MultiCast RX Problem

by slasher » Thu, 14 Oct 2010 02:08:38 GMT

Sponsored Links
 ood afternoon,

Platform is DROID X running V2.2OS. Have successfully connected to
Multicast server and am receiving broadcasts for a period of a period
of time (15-30 seconds) after which the receive function times out and
no other data is received. I can confirm the Multicast broadcast
remains active. Additionally, a restart of the application permits
reception of broadcast again (once again for about 15-30 seconds).
Broadcast is a simple text string approximately 30 ASCII characters
about 20 times a second.

Receive function is implemented in a separate thread as the Multicast
receive function is a blocking function.

If receive function is placed in main thread, this behavior does not
occur (i.e., I receive broadcasts indefinitely). However, I cannot
keep it in the main thread as there are a series of Multicast
receivers required for the application.

Have also tried numerous threading implementations (runnable, callable
as defined below) as well as extremely large buffers. It appears (and
this is purely an observation of the behavior, not a diagnosis) that
the network stack somehow fails to de-allocate memory on each receive
and that eventually is corrupted.

Code Follows...

Any thoughts or help is greatly appreciated. Thanks in advance.


public class Video1 extends Activity
MulticastSocket TheSocket;
final Handler mHandler = new Handler();

// Create runnable for posting
final Runnable mUpdateResults = new Runnable()
public void run()

protected void CompassReceive()
// final Runnable CompassReceive = new Runnable()
Thread t = new Thread()
public void run()
int idx;
byte[] buf = new byte[256];
boolean rcvd = false;

String response = "";
DatagramPacket packet = new
for (idx = 0 ; idx < buf.length ; idx++)
buf[idx] = 0;

rcvd = false;
response = new String(packet.getData()).trim();
Listener.doInBackground: Received:
"+packet.getAddress()+" "+packet.getPort()+" "+response);
rcvd = true;
catch (Exception e)
System.out.println("DEBUG: Rx Timeout");
rcvd = false;

private void updateResultsInUi()


public void onCreate(Bundle savedInstanceState)

WifiManager wifi =
MulticastLock lock = wifi.createMulticastLock("mylock");

Other Threads

1. Eclipse cannot find MediaMetadataRetriever class


I am using Eclipse Ganymede with Android SDK 1.0 r1 on a WinXP.  I am
trying to import but it seems that this class is
not part of the SDK, even though other classes
such as MediaPlayer are there.  Any idea how do i fix it?




Does anybody know where is this class defined in the source tree? -
Search turns up nothing. Is it not released in java source?

- Wen


3. How to open the keyboard in emulator?

4. How can I add a jar file to android app?

5. developer needed to write a theme application

6. Android Dev Phone detail?

7. Documents for Opencore