public void GettingHosts()
        {
            CreatePorts();

            try
            {
                tcpListenerHosts = new TcpListener(IPAddress.Any, NetSettings.PORT_FOR_HOSTS);
                tcpListenerHosts.Start();
                Console.WriteLine("The main Host-Server is running. Waiting for connections...");

                while (true)
                {
                    var tcpClient = tcpListenerHosts.AcceptTcpClient();

                    var result = ports.TryPop(out int port);
                    if (!result)
                    {
                        continue;
                    }

                    var hostServer = new HostServer(tcpClient, port, this);
                    Task.Run(new Action(hostServer.HandlingMessagesHost));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"\n\nException in MainHostServer!\nTargetSite:{ex.TargetSite}\n {ex.Message}\n StackTrace:{ex.StackTrace}");
                DisconnectHosts();
            }
        }
 public void AddConnectionHost(string id, int port, HostServer hostServer)
 {
     if (hosts.TryAdd(id, hostServer))
     {
         Console.WriteLine($"Host-Server is connected: Port = {port}, ID = {id}");
     }
     else
     {
         Console.WriteLine($"Host-Server with such ID = {id} and Port = {port} is already connected!");
     }
 }