端口扫描程序java实现

怎么样扫描计算机系统本地和远程的端口,监测其是打开还是关闭的在很多应用程序中都要用到,下面是用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日记:学习java一年体会1
下一篇:java.lang.ClassCastException翻译
最新评论共有 0 位网友发表了评论 , 查看所有评论
发表评论( 不能超过250字,需审核,请自觉遵守互联网相关政策法规。 )
匿名?
数据挖掘网站导航 数据挖掘论坛导航
  • 数据挖掘工具
  • 数据挖掘论坛
  • DataCruncher - Cognos
  • MineSet - MathSoft
  • Intelligent Miner - GainSmarts
  • Sqlserver - SAS - Clementine
  • CART - Weka - WizSoft
  • NeuroShell - ModelQuest
  • data mining tools - Darwin
  • 数据挖掘交友
  • 数据挖掘博客
  • 数据挖掘工具
  • 数据挖掘资源
  • 数据挖掘技术算法
  • 数据挖掘相关期刊、会议
  • 研究院联盟合作专区
  • 数据挖掘基础与相关技术
  • 数据挖掘厂商与就业
  • 数据挖掘研究者乐园
  • 知名厂商数据挖掘工具资料
  • 国内数据挖掘实验室
  • Foreign Data Mining Lab
  • 热点关注
  • 尚学堂J2EE和MLDN的J2EE视频教程哦
  • 有谁知道ERROR:JDWP Unable to get
  • com.microsoft.sqlserver.jdbc.SQLServerEx
  • 急~Eclipse3.3语言包,VEP插件
  • 毕业5年了,大家一个月全部收入能拿多少(税
  • org.hibernate.exception.ConstraintViolat
  • hibernate抛出could not fetch initial val
  • hibernate left outer join 出错 Path expe
  • myeclipse5.1.0和myeclipse6.0有什么区别。
  • spring如何动态获取bean,如何动态调用getB
  • 论坛最新话题
  • Foundations of Statistical Natural Langu
  • Game Theory meet Data Mining: A Recent P
  • System Building: How does it help or hin
  • 数据挖掘与Clementine培训
  • 新手报到
  • 求 SASEM 客户流失预测分析
  • 数据挖掘工程师/搜索研究院—北京——无线
  • 数据挖掘入门介绍(如何着手数据挖掘)
  • Information Overload Survey Results
  • The INEX 2005 Workshop on Element Retrie
  • 相关资讯
  • 不安装jre能运行JAVA程序吗?
  • Java的模板引擎Velocity用户手册
  • 成为java高手的八大条件
  • 简化Java代码的技巧
  • JAVA的网络功能与编程
  • 用java读取各种计算机文件系统的文件列表
  • 怎样拿下SUN公司的SCJP认证?
  • Borland以全额现金交易收购VMGEAR
  • 用JNI技术提高Java的性能
  • 用Java编写HTML文件分析程序
  • 数据挖掘实验室资料
  • 数据挖掘博客地址
  • 数据挖掘实验室网站地址
  • Prepare for Medicare audits by using dat
  • 注册成为SAS用户与爱好者俱乐部会员
  • 水南梅
  • 明日烟
  • 新人报道
  • 下载
  • 厦门服务器托管,450元/月—0592-5177319 高
  • 买空间送域名--0592-5177319 高静