C#判断远程计算机的指定端口是否打开

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

using System.Net;
if(!string.IsNullOrEmpty(txtPort.Text))
{
    IPAddress ip = IPAddress.Parse(txtIp.Text);
    IPEndPoint point=new IPEndPoint(ip,int.Parse(txtPort.Text));
    try
    {
        TcpClient tcp=new TcpClient();
        tcp.Connect(point);
        MessageBox.Show("端口打开");
    }catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}