Hello,
I have a thread that constantly polls a UDP connection and posts the
received data to another thread. It uses a connected DatagramSocket,
reads a packet (which is always the same side), gets the data and
posts it.

Code looks like:

protected void work() {
   byte[] buffer = new byte[SOME_BUFFER_SIZE];

   // Read UDP packet
   DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
   long startTime = System.currentTimeMillis();
   socket.receive(packet);
   long elapsed = System.currentTimeMillis() - startTime;
   Log.out.d("UDPReader: time for socket read: " + elapsed);

   // Post the data

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to