网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > Java
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.手把手教你使用Java来编写ASP组件.
.编程基础入门:Java修饰词的总结.
.使用JFreeChart创建图象.
.如何在代码中自动实现设计规范(组.
.使用Jakarta Commons Pool处理对.
.谈谈Java:Checked Exception与R.
.使用java.util.Calendar返回间隔.
.Gel:号称世界上最轻巧的Java&nb.
.Java环境的搭建.
.Jbuilder7与Weblogic7整合开发之.
.PreparedStatement.
.技术前沿:网格帮助SOA扩大规模.
.实现游戏开发中的屏幕滚动功能.
.报表系统Eclipse BIRT 2.0 M3发布.
.即时日志记录:使用 Jabber 增强.
.Java文件操作大全(1).
.Java Applet程序设计基础.
.用SQLJ开发数据库(3).
.(10)CDC API.
.jdbc连接各种数据库方式列表.

端口扫描程序java实现

发表日期:2008-1-5



  怎么样扫描计算机系统本地和远程的端口,监测其是打开还是关闭的在很多应用程序中都要用到,下面是用Java实现的简单的端口扫描程序。

Source Code:



--------------------------------------------------------------------------------


/*
* Created on 2005-3-22
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/

/**
* @author whandey connect to me: whandey@163.com
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import java.io.*;
import java.net.*;
import java.util.*;


public class SocketPort {

public static void main(String[] args) {

String ip = "159.162.39.27";
String hostname = new String();

try{ //get the target ip address and hostname
InetAddress address = InetAddress.getByName(ip);
System.out.println(address);
hostname = address.getHostName();
System.out.println(hostname);
}
catch(UnknownHostException e)
{
System.out.println("Could not find "+ ip);

}


try
{ // creat the output file
PrintWriter fout = new PrintWriter( new FileWriter("PortInf.txt"));
fout.println("Information Of The Port On the " + hostname +"computer ");
fout.println();

// do ports scan
for(int nport = 25;nport < 30;++nport)
{
try
{

Socket s = new Socket(hostname,nport);
fout.println("The port " + nport + " is open!");

fout.println("Connected to "+ s.getInetAddress() + " on port " + s.getPort() + " from port "+ s.getLocalPort() + " of " + s.getLocalAddress());
//print the connected socket information
}

catch(IOException e)
{
fout.println("The port " + nport + " is closed!");
}

}
fout.close();

}
catch(IOException e){}

}
}
上一篇:递归函数之JAVA演绎 人气:763
下一篇:第二讲 Java语言基础知识 人气:778
浏览全部Java的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐