当前位置:首页 > 网站技术 > ASP.NET

ASP.NET网上追捕实例代码

...

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

<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Net.Sockets" %>
<%@ Import Namespace="System.IO" %>
<script language="C#" runat=server>
protected void Page_Load(Object Src, EventArgs E){
TCPClient tcpc = new TCPClient();
String host="host";
showmsg.Text=TcpConnect(tcpc,host,25); //SMTP 端口
/*
showmsg.Text=TcpConnect(tcpc,host,80); //WWW 端口
showmsg.Text=TcpConnect(tcpc,host,21); //FTP 端口
showmsg.Text=TcpConnect(tcpc,host,110); //Pop 端口
showmsg.Text=TcpConnect(tcpc,host,1080); //Socket5 端口 代理服务器使用的端口
showmsg.Text=TcpConnect(tcpc,host,53); //DNS 端口
*/
}
String TcpConnect(TCPClient tcpc,String host,int port){
StreamReader sr ;
String strRet="123";
if(0 == tcpc.Connect(host,port)){
//联结服务器成功
sr = new StreamReader(tcpc.GetStream(), Encoding.Default);
strRet=sr.ReadLine();
}
return strRet;
}
</script>
<html>
<head>
<title>网络追捕</title>
<link rel="stylesheet" type="text/css" href="/doufu.css">
</head>
<body>
<asp:Label id=showmsg runat=server />
</body>
</html>

继续阅读
HttpRequest登录网站并获取网站信息实例
ASP.NET编写留言本实例
ASP.NET网页动态生成饼图代码
ASP.NET动态生成一个gif图片
ASP.NET的Ajax实现方式
ASP.NET中Server对象的方法
ASP.NET的Request对象属性介绍
ASP.NET2.0的URL映射的实现方法
ASP.NET的六种验证控件
发表评论

昵称:
最新评论
暂时没有评论!