コード例 #1
0
        /// <summary>
        /// Buscar todos los servers disponibles de la LAN bajo el puerto especificado
        /// </summary>
        public List <TgcAvaliableServer> findLanServers(int port)
        {
            TgcLanBrowser             lanBrowser       = new TgcLanBrowser();
            List <string>             computersDomains = lanBrowser.getNetworkComputers();
            List <TgcAvaliableServer> servers          = new List <TgcAvaliableServer>();

            foreach (string computerDomain in computersDomains)
            {
                //Intentar conectarse
                try
                {
                    IPAddress[] addresses = Dns.GetHostAddresses(computerDomain);
                    IPAddress   address   = addresses[0];
                    servers.Add(new TgcAvaliableServer(computerDomain, address.ToString()));
                }
                catch (Exception)
                {
                    //Hubo algún problema un una IP, ignorar en la lista
                }
            }

            return(servers);
        }
コード例 #2
0
        /// <summary>
        /// Buscar todos los servers disponibles de la LAN bajo el puerto especificado
        /// </summary>
        public List<TgcAvaliableServer> findLanServers(int port)
        {
            TgcLanBrowser lanBrowser = new TgcLanBrowser();
            List<string> computersDomains = lanBrowser.getNetworkComputers();
            List<TgcAvaliableServer> servers = new List<TgcAvaliableServer>();

            foreach (string computerDomain in computersDomains)
            {
                //Intentar conectarse
                try
                {
                    IPAddress[] addresses = Dns.GetHostAddresses(computerDomain);
                    IPAddress address = addresses[0];
                    servers.Add(new TgcAvaliableServer(computerDomain, address.ToString()));
                }
                catch (Exception)
                {
                    //Hubo algún problema un una IP, ignorar en la lista
                }

            }

            return servers;
        }