Search Unity

IPv6 anyone?

Discussion in 'Scripting' started by Ozelo, Apr 23, 2014.

  1. Ozelo

    Ozelo

    Joined:
    Sep 5, 2012
    Posts:
    5
    Hello,

    I am trying to connect to a raw socket IPv6 host with no success. Please help.

    Whenever I try this I get the same exception.

    I am using Unity 4.2.0, .NET 4.5.1, Win 7 and the system has both IPv4 and IPv6 TCP stacks enabled, as shown in this output:
    Code (csharp):
    1. F:\Users\Ozelo\Downloads\AsyncResolveNameChap6CS\AsyncResolveNameChap6CS\AsyncRe
    2. solveNameChap6CS\bin\Debug>AsyncResolveNameChap6CS.exe google.com
    3. BeginGetHostEntry() is OK...
    4. Press any key to stop this program...
    5.  
    6. The primary host name is: google.com
    7. No Aliases found...
    8. IP addresses found are:
    9. IPv6 Address #1 is 2800:3f0:4001:817::1005
    10. IPv4 Address #1 is 173.194.118.232
    11. IPv4 Address #2 is 173.194.118.224
    12. IPv4 Address #3 is 173.194.118.233
    13. IPv4 Address #4 is 173.194.118.226
    14. IPv4 Address #5 is 173.194.118.225
    15. IPv4 Address #6 is 173.194.118.238
    16. IPv4 Address #7 is 173.194.118.229
    17. IPv4 Address #8 is 173.194.118.227
    18. IPv4 Address #9 is 173.194.118.228
    19. IPv4 Address #10 is 173.194.118.230
    20. IPv4 Address #11 is 173.194.118.231
    21. Finished querying DNS.
    22.  
    23. Read() is OK...
    24.  
    The program used to check if GetHostEntry works can be found here.

    For some reason I don't know, Socket.SupportsIPv6 return FALSE but Socket.OSSupportsIPv6 return TRUE. This is the code I did on Unity that is NOT giving me any IPv6 address:
    Code (csharp):
    1. #pragma strict
    2. import System.Net;
    3. import System.Net.Sockets;
    4.  
    5. private var ipv6addr="unavailable?";
    6. private var ipv4addr="unavailable?";
    7. private var ssipv6="TRUE";
    8. private var osipv6="TRUE";
    9.  
    10. function Start() {
    11.     if (!Socket.SupportsIPv6) ssipv6 = "FALSE";
    12.     if (!Socket.OSSupportsIPv6) osipv6 = "FALSE";
    13.     var RemoteHost: IPHostEntry = Dns.GetHostEntry("google.com");
    14.     for (var ASimpleIPAddr: IPAddress in RemoteHost.AddressList) {
    15.         if (ASimpleIPAddr.AddressFamily != AddressFamily.InterNetwork) ipv6addr = ASimpleIPAddr.ToString();
    16.         else ipv4addr = ASimpleIPAddr.ToString();
    17.     }
    18. }
    19.  
    20. function OnGUI() {
    21.     var mX = (Screen.width / 2);
    22.     var mY = (Screen.height / 2);
    23.     var box_width = mX;
    24.     var box_height = mY;
    25.     var box_lx = mX - (box_width / 2);
    26.     var box_ly = mY - (box_height / 2);
    27.     GUI.Box(Rect(box_lx, box_ly, box_width, box_height), "DUAL STACK INFO");
    28.     GUI.Label(Rect(box_lx + 6, box_ly + 30, box_width, 20), "IPv6 Address:  " + ipv6addr);
    29.     GUI.Label(Rect(box_lx + 6, box_ly + 45, box_width, 20), "IPv4 Address:  " + ipv4addr);
    30.     GUI.Label(Rect(box_lx + 6, box_ly + 60, box_width, 20), "Socket.OSSupportsIPv6?   " + osipv6);
    31.     GUI.Label(Rect(box_lx + 6, box_ly + 75, box_width, 20), "Socket.SupportsIPv6?   " + ssipv6);
    32. }
    33.  
     
  2. Ozelo

    Ozelo

    Joined:
    Sep 5, 2012
    Posts:
    5
    I just found that the Unity3D code above works perfectly on Linux Ubuntu 12.04 and I don´t know why it won't work on my Windows 7 station... I am clueless. :(
     
  3. Ozelo

    Ozelo

    Joined:
    Sep 5, 2012
    Posts:
    5
    I am clueless, definitely. The same code. I couldn't figure why it works on Linux but does NOT work on Windows. Both machines have IPv6 enabled. Please, could any of you test it and give me some feed-back if it works on your system? It should state how are your dual stack and give back the google.com IPv4 and IPv6 addresses. Here are the files:

    IPCheck.rar (Windows version)

    LIPCheck.rar (Linux version)
     
  4. Nicolas1212

    Nicolas1212

    Joined:
    Dec 18, 2014
    Posts:
    139
    We have this same problem on 5.3.5 - it came down to using ".Net 2.0" compatibility in the player build settings rather than ".Net 2.0 Subset". I'm not sure *why* it works, as technically .Net 2.0 should have everything that the subset has and more, but try switching them.

    This is the bug report if you're interested: https://fogbugz.unity3d.com/default.asp?804510_c5ei44diq6ktnh1u

    Also, in this thread (http://forum.unity3d.com/threads/unity-ios-and-ipv6-support.404938/#post-2676696) they specifically said they didn't backport some IPv6 fixes to the Unity4 windows branch, so it might just be that as well.