Author Topic: TNServerInstance.localAddress on iOS  (Read 3837 times)

Adriaan

  • Guest
TNServerInstance.localAddress on iOS
« on: February 12, 2013, 04:23:32 PM »
Hi there!

I've managed to make a shared multiplayer room cross platform with multiple clients connected and that is friggin awesome! I've been hosting in the editor so far and haven't had any troubles.

But here's the deal. If I make a server on iOS and try to call 'TNServerInstance.localAddress', it doesn't continue with any of the code after that line and outputs the following in the console:

  1. SocketException: No such host is known
  2.   at System.Net.Dns.hostent_to_IPHostEntry (System.String h_name, System.String[] h_aliases, System.String[] h_addrlist) [0x00000] in <filename unknown>:0
  3.   at System.Net.Dns.GetHostByName (System.String hostName) [0x00000] in <filename unknown>:0
  4.   at System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) [0x00000] in <filename unknown>:0
  5.   at System.Net.Dns.GetHostAddresses (System.String hostNameOrAddress) [0x00000] in <filename unknown>:0
  6.   at TNet.GameServer.get_localAddress () [0x00000] in <filename unknown>:0
  7.   at TNServerInstance.get_localAddress () [0x00000] in <filename unknown>:0
  8.   at GameManager.OnGUI () [0x00000] in <filename unknown>:0
  9.  
  10. (Filename:  Line: -1)

Did it fail to make a server on iOS? Or what exactly is happening? Can anyone help me out?

Thanks a lot!!!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNServerInstance.localAddress on iOS
« Reply #1 on: February 13, 2013, 01:17:22 PM »
Is your iOS device actually connected to the wireless network? If DNS fails, it suggests it's not.

Adriaan

  • Guest
Re: TNServerInstance.localAddress on iOS
« Reply #2 on: February 25, 2013, 02:12:50 PM »
It is...

If I start the server in the Editor, my phone is perfectly able to connect and sync data.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNServerInstance.localAddress on iOS
« Reply #3 on: February 25, 2013, 06:03:09 PM »
Not sure what's going on there -- my android devices are able to host just fine. I suggest debugging the localAddress function. All it does inside is queries the DNS to determine your local IP address. You can also try replacing it with this:
  1.         static public IPAddress localAddress
  2.         {
  3.                 get
  4.                 {
  5.                         if (mLocalAddress == null)
  6.                         {
  7.                                 try
  8.                                 {
  9.                                         IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName());
  10.  
  11.                                         for (int i = 0; i < ips.Length; ++i)
  12.                                         {
  13.                                                 IPAddress addr = ips[i];
  14.  
  15.                                                 if (IsValidAddress(addr))
  16.                                                 {
  17.                                                         mLocalAddress = addr;
  18.                                                         break;
  19.                                                 }
  20.                                         }
  21.                                 }
  22. #if DEBUG
  23.                                 catch (System.Exception ex)
  24.                                 {
  25.                                         System.Console.WriteLine("TNTools.LocalAddress: " + ex.Message);
  26. #else
  27.                                 catch (System.Exception)
  28.                                 {
  29. #endif
  30.                                         mLocalAddress = IPAddress.Loopback;
  31.                                 }
  32.                         }
  33.                         return mLocalAddress;
  34.                 }
  35.         }

Adriaan

  • Guest
Re: TNServerInstance.localAddress on iOS
« Reply #4 on: March 09, 2013, 07:22:23 AM »
So... I saw you updated TNET today and removed the localAddress completely! So... The question is: how am I going to run a server on my iPhone and know how to connect to it?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNServerInstance.localAddress on iOS
« Reply #5 on: March 09, 2013, 11:51:51 AM »
TNet.Tools.localAddress