Search Unity

BeginGetHostEntry not resolving hostname @runtime

Discussion in 'Multiplayer' started by cliv3dev, Sep 19, 2017.

  1. cliv3dev

    cliv3dev

    Joined:
    May 17, 2017
    Posts:
    5
    Hi,

    I use the functions Dns.BeginGetHostEntry() / Dns.EndGetHostEntry() to find the ip address of another PC on the network. It retrieves the right ip when I launch the code in the editor, but when I compile with Visual Studio the runtime with the same code and same hostname, I get the ip address of the host running the runtime and not the hostname (for example hostname="google.com").
    Any advice to make that work in runtime mode ?

    thanks
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    So you're compiling with Visual Studio and not creating your build in Unity? People will also need to see your code to comment on what is going wrong with it.
     
  3. cliv3dev

    cliv3dev

    Joined:
    May 17, 2017
    Posts:
    5
    I'm creating the build in Unity (target is UWP with 'Unity C# projects' flag ON to generate VS project) and then open the generated .sln and I compile it in VS.

    So the problem arises when I build with UWP target. If I select PC/Windows target and build directly in Unity, the runtime resolves the hostname as expected (doesn't return the IP of the host the runtime is running on)...

    My code is attached.

    [update]
    If I select scripting backend: .NET, the problem arises (ip is the host the runtime is running on).
    If I selected scripting backend: IL2CPP, there is no problem (ip is the good one).

    Thanks !
     

    Attached Files:

    Last edited: Sep 20, 2017
  4. cliv3dev

    cliv3dev

    Joined:
    May 17, 2017
    Posts:
    5
    Hi,

    anyone did have this problem ? I can't believe I'm alone to try this kind of stuff :)
    Any help appreciated !

    Thanks,