if you need to receive UDP datagram, better use write it in C using NDK???

35 views
Skip to first unread message

HeHe

unread,
Jan 22, 2010, 1:20:03 PM1/22/10
to android-ndk
just traced into Dalvik's
org_apache_harmony_luni_platform_OSNetworkSystem.cpp module and found
that, regardless if i set receive timeout by setSoTimeout(), my Java
thread which calls receive() actually gets into a loop in
pollSelectWait() function in the .cpp module above. surprisingly, the
function wakes up every 100000us (100ms).

that means, my java thread using DatagramSocket is not 100% free of
cpu usage on calling DatagramSocket.receive().

from observation, the "utime/stime" columns of "Threads" tab window of
DDMS perspective keeps counting though slowly.

does it mean that i need to rewrite my java UDP receiver in C using
NDK? using BSD socket in C, a blocking read means 200% blocking, not
consuming any drop of cpu.

Reply all
Reply to author
Forward
0 new messages