Closed GoogleCodeExporter closed 9 years ago
After some tracing, I found the problem in the UdpServer receive code. When a
UDP packet is received on certain phones, the following call seems to take a
very long time (~120ms):
packet.getSocketAddress();
Oddly, on other phones, this call takes almost no time at all.
Original comment by psi...@gmail.com
on 22 Nov 2011 at 4:03
Ok, figured it out. The problem is apparently a bug in the
InetSocketAddress/InetAddress constructors. When "new InetSocketAddress()" is
called, it calls InetAddress.getHostname(), which triggers a reverse DNS lookup
that takes a long time if there is no hostname. On incoming UDP packets, this
hostname is often unresolved, since the address in the packet is just numeric.
See:
http://mailinglists.945824.n3.nabble.com/Android-and-reverse-DNS-lookup-issues-t
d3011461.html
I could add a hostname using InetAddress.getByAddress(String, byte[]), but
there is a bug in this code where the hostname is not specified. So instead I
put in a workaround that uses reflection to directly manipulate the hostname,
filling in a dummy string that prevents a reverse DNS call from happening.
See:
http://code.google.com/p/android/issues/detail?id=13117#c14
The issue should no longer occur after the patch in r572.
Original comment by psi...@gmail.com
on 22 Nov 2011 at 4:09
Original issue reported on code.google.com by
psi...@gmail.com
on 22 Nov 2011 at 4:02