int FindOneOpenPort()
 {
     if (Application.platform == RuntimePlatform.WindowsPlayer)
     {
         int         ProcessID = System.Diagnostics.Process.GetCurrentProcess().Id;
         List <Port> ports     = OSUtils.GetNetStatPorts();
         List <int>  portids   = new List <int>();
         foreach (Port port in ports)
         {
             if (port.pid == ProcessID && port.state == "LISTENING")
             {
                 portids.Add(port.port_number);
             }
         }
         if (portids.Count == 1)
         {
             return(portids[0]);
         }
     }
     return(-1);
 }
    public void DoGetPorts()
    {
        OpenedPort.text = "";
        int ProcessID = System.Diagnostics.Process.GetCurrentProcess().Id;

#if UNITY_EDITOR
        ProcessID = 47056;
        List <Port> ports  = new List <Port>();
        string      output = Resources.Load <TextAsset>("NetCatOutput").text;
        OSUtils.ParseNetcatOutput(output, ports);
#else
        List <Port> ports = OSUtils.GetNetStatPorts();
#endif
        foreach (Port port in ports)
        {
            if (port.pid == ProcessID && port.state == "LISTENING")
            {
                OpenedPort.text = OpenedPort.text + port.port_number + " ";
            }
            Debug.Log("Ports : " + port.name);
        }
    }