查看端口信息
求 查看本地端口的代码
我写的
string strResult;
TcpClient tcpc = new TcpClient();
try
{
tcpc.Connect("localhost", portNum);
Stream s = tcpc.GetStream();
StreamReader sr = new StreamReader(s, Encoding.Default);
strResult = sr.ReadLine();
}
catch
{
strResult = "没有开放";
}
finally
{
//关闭 tcpClient
tcpc.Close();
}
反应 很慢 特别是在strResult = sr.ReadLine(); 而且结果好象也不对
求大家帮忙