Skip to content Skip to sidebar Skip to footer

Issue With Datagramsocket On Android 7.1.1

I'm faced with a very strange issue on QA's Google Pixel with Android 7.1.1 (N_MR1). We use UDP Server and Client for handshake during establish the TCP connection. QA reports that

Solution 1:

The issue is in the port you use. On my Pixel phone the following port ranges are defined in the /proc/sys/net/ipv4/ip_local_reserved_ports file:

32100-32600,40100-40150

If I change the port number in your code to anything out of this range (and above 1024, of course), it works fine and I'm able to send data to the app from the other host.

Linux Kernel documentation describes this file like this:

ip_local_reserved_ports - list of comma separated ranges

Specify the ports which are reserved for known third-party applications. These ports will not be used by automatic port assignments (e.g. when calling connect() or bind() with port number 0). Explicit port allocation behavior is unchanged.

So, when you explicitly pass the port number to the bind method it should still be possibly to use those ports. Apparently this doesn't work. In my opinion, there is a bug somewhere in the network-stack provided by the Linux Kernel implementation used in Android. But this requires additional investigation.

You may also find useful the following list of ip_local_reserved_ports contents on different phones: https://census.tsyrklevich.net/sysctls/net.ipv4.ip_local_reserved_ports

Post a Comment for "Issue With Datagramsocket On Android 7.1.1"