Search Unity

How to get subnet mask on mobile device

Discussion in 'Multiplayer' started by hiyuch, Oct 21, 2015.

  1. hiyuch

    hiyuch

    Joined:
    Aug 28, 2014
    Posts:
    1
    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?
     
  2. mitsubuchi

    mitsubuchi

    Joined:
    Jul 4, 2012
    Posts:
    1
    192.168.1.1 Address is class C IP address
    So you may set 255.255.255.0 or smaller subnet mask
     
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    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.