网上追捕(很多实用的port)

豆腐制作 都是精品
http://www.asp888.net 豆腐技术站

我们可以在Asp.Net中通过使用Sockets Class 来对InterNet 上的主机进行远程的控制和探测(不要搞破坏呀!)
下面的例子中豆腐给大家提供一个例子,可以对 指定的主机进行 探测:)功能类似 追捕。

1@ Import Namespace="System.Net" 
1 @Import Namespace="System.Net.Sockets" 
1@ Import Namespace="System.IO" 
 1<script language="C#" runat="server">   
 2protected void Page_Load(Object Src, EventArgs E){   
 3TCPClient tcpc = new TCPClient();   
 4String host="host";   
 5showmsg.Text=TcpConnect(tcpc,host,25); //SMTP 端口   
 6/*   
 7showmsg.Text=TcpConnect(tcpc,host,80); //WWW 端口   
 8showmsg.Text=TcpConnect(tcpc,host,21); //FTP 端口   
 9showmsg.Text=TcpConnect(tcpc,host,110); //Pop 端口   
10showmsg.Text=TcpConnect(tcpc,host,1080); //Socket5 端口 代理服务器使用的端口   
11showmsg.Text=TcpConnect(tcpc,host,53); //DNS 端口   
12*/   
13}   
14String TcpConnect(TCPClient tcpc,String host,int port){   
15StreamReader sr ;   
16String strRet="123";   
17if(0 == tcpc.Connect(host,port)){   
18//联结服务器成功   
19sr = new StreamReader(tcpc.GetStream(), Encoding.Default);   
20strRet=sr.ReadLine();   
21}   
22return strRet;   
23}   
24</script>
1<html>
2<head>
3<title>网络追捕</title>
4<link href="/doufu.css" rel="stylesheet" type="text/css"/>
5</head>
6<body>
7<asp:label id="showmsg" runat="server"></asp:label>
8</body>
9</html>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus