扫描端口的程序,不要太复杂,我是新手,希望大家能帮助我,谢谢。
解决方案 »
- 如何用GridBagLayout实现这样的布局,在线等急 !!!
- String类下为什么没有finalize()?
- arraylist中存了个arraylist,那怎么读数据?
- 求助:我想做一个要使用扫描仪的java桌面程序,请问需要什么类包?
- 刚复习玩J2SE,想问现在我可以进军Servlet JSP了吗?
- java开发交流群号8337229
- jdk开发学生信息管理系统的用户界面遇到的问题
- 如何控制JTextField 中的输入格式,如只能输入数字、最大只能输入n位,多了则不能输入
- 用JAVA做多媒体处理
- 无法解决的问题。(在线等)
- 导入到下面的程序,怎么出现软件包 com.bruceeckel 不存在,是我的路径有问题吗?
- 简单的小问题.自己搞不定了!
import java.net.*;
class scan extends Thread
{
static int port=1;
public static void main(String args[]) throws Exception
{
String host="127.0.0.1";
int num=100;
try{
if(args[0]!=null)host=args[0];
if(args[1]!=null)num=Integer.parseInt(args[1]);
}catch(Exception e){}
System.out.print("扫描"+host+"从端口1到"+num+"开始");
if(num<=0)num=100;
new everyrun(num);
for(;port<=num;port++)
{
new every(host,port).start();
while(every.num>50&&port<=num)sleep(10);
}//while
System.exit(0);
}//main
}//class
class every extends Thread
{
static int num=0;
String host;int port;
every(String nh,int np)
{host=nh;port=np;num++;}
public void run()
{
try{
Socket ss=new Socket(host,port);
System.out.println("\r......\t端口:"+port+"开放");
ss.close();
num--;
}catch(Exception e){num--;}
}
}
class everyrun extends Thread
{
int num;
public everyrun(int num)
{this.num=num;start();}
public void run()
{
System.out.println();
try{
while(scan.port<=num)
{
System.out.print("...");sleep(500);
System.out.print("\b \b");sleep(500);
System.out.print("\b \b");sleep(500);
System.out.print("\b \b");sleep(500);
System.out.print(".");sleep(500);
System.out.print(".");sleep(500);
System.out.print("\b\b");
}
}catch(Exception e){}
}
}
you need to use c double plus or c to complete the function
because the java did't supply the API to support raw socket or third layer
protocol.
A better way to find the remote host port thru have-opend scan!