TcpClient of .Net allows me to test if a connection can be stablished, so, let me know if the remote port is Open.
Check this code:
TcpClient tcpCLient = new TcpClient();
try
{
tcpCLient.Connect("www.google.com", 80);
Console.WriteLine("Yes");
Console.ReadLine();
}
catch (Exception)
{
Console.WriteLine("No");
Console.ReadLine();
throw;
}
I tested the Tcp port 80 of www.google.com and because it is open I see in the console a "Yes" message. Now, I'll try the TCP port 70 of www.google.com that is closed.
TcpClient tcpCLient = new TcpClient();
try
{
tcpCLient.Connect("www.google.com", 70);
Console.WriteLine("Yes");
Console.ReadLine();
}
catch (Exception)
{
Console.WriteLine("No");
Console.ReadLine();
throw;
}
I expected a exception, so I shoul see a "No" in the Console. Why Nothing happens? Thank you!!
Update:
The console keeps this way even after several minutes.