UDP Datagram packet receive loop delay
<p>I'm running a Thread with a an active loop waiting for UDP packets.</p>

<p>When message is received , I want to process it.</p>

<p>I need to receive several packets per second (~20).</p>

<p>I'm taking a minimalist example, just logging after receiving UDP packet</p>

<pre><code>while (socketUDP != null) {
    message = new byte[6];
    packet = new DatagramPacket(message, message.length);

    try {
        socketUDP.receive(packet);
        command = new String (message, 0, packet.getLength());
    } catch (IOException e) {
        Log.e(LOG_TAG, LOG_TAG + " IOException: " + e.getMessage() );
    }

    Log.d(LOG_TAG, "test");
}
</code></pre>

<p>The behaviour is weird, because, for example, I send 50 UDP packets in 1 second, no one is lost, and Android take's about 3/4 seconds to show the 50 log text message "test"!!</p>

<p>So, it seems that Android's VM is saving somewhere all packets in a buffer and process it when possible!</p>

<p>I need to process datagram's packets as soon as possible in Android.</p>

<p>It seems I'm missing something.</p>

<p>Any ideia wich is the best way to do that?!</p>
