0

当我检查特定主机的端口时,它报告端口 81 和 82 已打开。但是当我使用在线检查器时,他们报告说端口 81 和 82 已关闭。有什么问题?

static void Main(string[] args)
    {
        string host = "google.com";
        for (int port = 79; port < 83; port++)
        {
            IPAddress ipadr = Dns.GetHostAddresses(host)[0];

            try
            {
                Socket sock = new Socket(AddressFamily.InterNetwork,
                                            SocketType.Stream,
                                            ProtocolType.Tcp);
                sock.Connect(ipadr, port);
                if (sock.Connected)
                    Console.WriteLine("Port {0} is opened", port);
                sock.Close();

                //return;
            }
            catch (SocketException)
            {
                Console.WriteLine("Port {0} is closed", port);
            }
        }

        Console.ReadLine();
    }

但例如它报告端口 79 已关闭。有什么问题?

4

0 回答 0