Author Topic: Solved: Mac OS X 10.10 - SocketException: No such host is known  (Read 4206 times)

K93

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Hello TNet,

I keep getting this SocketException on Mac OS X 10.10. Normally I program on Windows but I recently switched to Mac OS X. I tried this on Windows once and it didn't give me an exception.

I googled a bit for it and they said it could be Mono which has errors with this. Though I am not for sure and I can not find a reference. The script already has an exception if Unity is being run on the iPhone, maybe it has to be done for Mac OS X too? Sometimes if I give up the ipAddress (Not 127.0.0.1) manually. The real IP Address I mean, not the loopback address or such, it works.

Some information about my environment:
Mac OS X 10.10 Public Preview 2,
Unity 4.5.3f (Free license),
MonoDevelop bundled with Unity 3D.
TNet 1.9.7,
Irrelevant assets:
2D Toolkit and 2D Platform Controller.

If I use the game client on Mac OS X as Standalone in x86_64 mode, it crashes as soon as I click the "Connect to Server" button.

If I use the Unity Editor to try out my game and press the Connect to Server button again the Console is giving me this exception and disables the TNManager script. As soon as I enable the TNManager script it starts loading my next scene.

This is my code, I removed the irrelevant pieces like Input boxes for portNumber and ipAddress.


  1. private string ipAddress = "localhost";
  2.         private string port = "25666";
  3.  
  4.         private int channelID = 0;
  5.         private string levelName = "CharacterControllerTest";
  6.         private bool persistent = true;
  7.         private string password = "";
  8.  
  9.         private string errorMessage = "";
  10.  
  11.         private bool selectedSave = false;
  12.  
  13.         void ConnectToServerWindow (int windowID) {
  14.                 GUILayout.BeginHorizontal ();
  15.                 int portOut;
  16.                 if(int.TryParse (port, out portOut) && portOut >= 1024 && portOut <= 49151 && selectedSave) {
  17.                         if (GUILayout.Button ("Connect to Server", GUILayout.ExpandWidth (true))) {
  18.                                 errorMessage = "";
  19.                                 TNManager.Connect(ipAddress, portOut);
  20.                         }
  21.                 }
  22.                 GUILayout.EndHorizontal ();
  23.  
  24.         }
  25.  


And here the Exception:
  1. SocketException: No such host is known
  2. System.Net.Dns.hostent_to_IPHostEntry (System.String h_name, System.String[] h_aliases, System.String[] h_addrlist)
  3. System.Net.Dns.GetHostByName (System.String hostName)
  4. System.Net.Dns.GetHostEntry (System.String hostNameOrAddress)
  5. System.Net.Dns.GetHostAddresses (System.String hostNameOrAddress)
  6. TNet.Tools.get_localAddresses () (at Assets/TNet/Common/TNTools.cs:142)
  7. TNManager.Awake () (at Assets/TNet/Client/TNManager.cs:937)
  8. UnityEngine.GameObject:AddComponent()
  9. TNManager:get_instance() (at Assets/TNet/Client/TNManager.cs:361)
  10. TNManager:Connect(String, Int32) (at Assets/TNet/Client/TNManager.cs:440)
  11. StartMenuUI:ConnectToServerWindow(Int32) (at Assets/Spire/Scripts/User Interface/StartMenuUI.cs:218)
  12. UnityEngine.GUI:CallWindowDelegate(WindowFunction, Int32, GUISkin, Int32, Single, Single, GUIStyle)
  13.  
« Last Edit: August 30, 2014, 02:00:48 PM by K93 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Mac OS X 10.10 - SocketException: No such host is known
« Reply #1 on: August 30, 2014, 09:47:30 AM »
Sounds like that would be the case, yes. My guess is they're removing some functionality in 10.10 that was already removed on iOS. Unfortunately there is no way to test for OS version on Unity that I'm aware of, is there? You'd need to comment out that entire section.

K93

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Mac OS X 10.10 - SocketException: No such host is known
« Reply #2 on: August 30, 2014, 01:59:39 PM »
I fixed it by adding the following to TNTools.cs:
  1. 139: #if !UNITY_IPHONE && !UNITY_EDITOR_OSX && !UNITY_STANDALONE_OSX