如何用c# web编程 探测FTP 端口是否开放
来源:百度知道 编辑:UC知道 时间:2024/06/07 00:49:57
是WEB编程,做网页的
使用
输入主机IP或域名,输入开始结束端口。
原理
主要使用了ASP.NET 2.0的System.Net.Sockets组件。
StartPort = Convert.ToInt32(numStart.Text);
EndPort = Convert.ToInt32(numEnd.Text);
ipAdres = txtIP.Text;
Thread[] pool = new Thread[(EndPort - StartPort) + 1];
int i = 0;
DateTime start = DateTime.Now;
// Loop through the ports between start port and end port
for (int CurrPort = StartPort; CurrPort <= EndPort; CurrPort++)
{
Thread th =
new Thread(new System.Threading.ParameterizedThreadStart(portAc));
//NOTE: better to leave to system.
// th.Priority = ThreadPriority.AboveNormal;
th.Start(CurrPort);
pool[i] = th;
i++;
}
#region thread pool
int k = --i;
int retryCount = 0;
for (; i >= 0; i--)
{
if (pool[i].IsAlive)
{
i = k;
retryCount++;
continue;