Beispiel #1
0
        private void Button_Click_6(object sender, RoutedEventArgs e)
        {
            int       port   = 8080;
            string    ip     = "127.0.0.1";
            TcpClient client = new TcpClient(ip, port);

            string[] hostNames = { "www.microsoft.com", "www.apple.com",
                                   "www.google.com",    "www.ibm.com",    "cisco.netacad.net",
                                   "www.oracle.com",    "www.nokia.com",  "www.hp.com",      "www.dell.com",
                                   "www.samsung.com",   "www.toshiba.com","www.siemens.com",
                                   "www.amazon.com",    "www.sony.com",   "www.canon.com",   "www.alcatellucent.com",
                                   "www.acer.com",      "www.motorola.com" };
            ;
            IPAddress[]   ipAddresses;
            var           permissionState = System.Security.Permissions.PermissionState.Unrestricted;
            DnsPermission dnsPermission   = new DnsPermission(permissionState);

            dnsPermission.PermitOnly();
            for (var index = 0; index < hostNames.Length; index++)
            {
                string hN = hostNames[index];
                ipAddresses     = Dns.GetHostAddresses(hN);
                ipAddress.Text += hN + " => \n" + ipAddresses.ToString() + "\n";
            }
        }