How to get subnet mask on mobile device

Hi,
I want my app could auto find the ip address of server.
I used udp broadcast to remind server then server will send a udb package to my mobile device.
Mobile can refer the source address of the package to setup ip address of server.

My problem is, the general broadcast address(255.255.255.255) cannot work correctly,
I need subnet mask to caculate the broadcast address. For example:
ip address is:192.168.1.1
subnet mask is:255.255.128.0
the broadcast address will be: (192.168.1.1 | (~255.255.128.0)) =192.168.127.255
But unity not implemented System.Net.NetworkInformation.GetAllNetworkInterfaces() on android,
so i cannot get the subnet mask using C#.

Is there any way to get subnet mask on mobile device?

192.168.1.1 Address is class C IP address
So you may set 255.255.255.0 or smaller subnet mask

He’s not trying to set the subnet mask. He’s trying to get the currently set mask. IP address classes are pretty meaningless today with modern network architectures the way they are by the way.