当我检查特定主机的端口时,它报告端口81& 82开了。 但是,当我使用在线检查器时,他们报告了81和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已关闭。 有什么问题?