Search Unity

Question Issue Finding Open UDP Port?

Discussion in 'iOS and tvOS' started by SkyTech6, Oct 13, 2020.

  1. SkyTech6

    SkyTech6

    Joined:
    Jul 14, 2015
    Posts:
    151
    Hey guys, I'm trying to find an available open udp port on iOS and it's giving me some issues.

    Code (CSharp):
    1.  
    2. private static readonly IPEndPoint DefaultLoopbackEndpoint = new IPEndPoint(IPAddress.Loopback, port: 0);
    3.     private int FindAvailableUDPPort()
    4.     {
    5.         using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))
    6.         {
    7.             socket.Bind(DefaultLoopbackEndpoint);
    8.             return ((IPEndPoint)socket.LocalEndPoint).Port;
    9.         }
    10.     }
    This works on Windows, Android, and OSX. However on iOS with XCode building in Release will result in the following error occuring (the last before the app freezes)

    Warning: Libinfo call to mDNSResponder on main thread

    At this point the app also freezes. This error however is highly unfortunate to google and doesn't result in much.

    However, if I were to build this as a Debug schema in XCode, it will run perfectly fine... Anyone have any ideas to point me in the right direction?
     
  2. SkyTech6

    SkyTech6

    Joined:
    Jul 14, 2015
    Posts:
    151
    silence sadness bump