代码语言:javascript复制
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);
}
}