Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.
Options

Hololens IP address mysteries in Unity

utzyutzy
edited July 2017 in Questions And Answers

I am trying to display the local IP address of my Hololens in Unity. Specifically I mean the LAN IPv4 address you also use for the device portal and which can be found under Settings > Network > Advanced options.
Unfortunately all methods I have tried, work fine in the editor, but will not build for the Hololens (WSA).

So far I have tried the following:

IPHostEntry host;
string localIP = "";
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
    {
        if (ip.AddressFamily == AddressFamily.InterNetwork)
        {
            localIP = ip.ToString();
            break;
        }
    }
return localIP;
  • Gives error: 'Dns' does not contain a definition for 'GetHostName' and 'GetHostEntry'
UnityEngine.Network.player.ipAddress
  • Gives error: The name 'Network' does not exist in the current context
UnityEngine.Networking.NetworkManager.singleton.networkAddress
  • Does not return the local IP, but the server's IP.

Would anyone happen to have another idea, how to get the local IP in UNet on the Hololens?
Am I doing something wrong?

Answers

  • Options

    Or would you even advise against using UNet to do shared experiences and instead go for Photon or something?

  • Options

    just FYI, our solution was to write a little native library to get at the IP of the Hololens.

  • Options

    Its September 2018. And I am facing this problem now... The same code of DNS.GetHostName() written in Unity works properly when built for iPad. Now when I am trying to build it for Hololens, its showing this error.

  • Options

    One workaround is

    • When a client connects to server, server delegate (obviously on the server side) function OnClientConnected is called with a connection parameter(NetworkConnection conn). The conn.id is something which is unique at server side, though may not match with conn.id at client's end. But this conn parameter has conn.ipAddress. which will give you the client(Hololens's) ipaddress. You may wish to send it back to Hololens if you want Hololens to have it.

    -In my project, I might need it in future, but currently, I am maintaining a dictionary of connID: ipAddress] and another dictionary of [ipAddress: playergameObject] at server end to track players.

    Hope it might help...

Sign In or Register to comment.