import java.io.*;
import java.net.*;public class scanner
{
public static void main (String[] args) 
{
MoreThread threadobj=new MoreThread();
System.out.println("Scanning……");
for(int i=1;i<=5000;i++)
{
new MoreThread(threadobj,"i").start();
}


}
}
class MoreThread implements Runnable
{
String host;
    int port;
Socket MoreThread=null;
DataOutputStream os=null;
DataInputStream is=null;
    MoreThread(String host, int port)
    {
     this.host=host;
        this.port=port;
    } public void run()
{
try
{
for(int i=1;i<=65535;i++)
{
MoreThread=new Socket("127.0.0.1",i);
os=new DataOutputStream(MoreThread.getOutputStream());
is=new DataInputStream(MoreThread.getInputStream());
} }
/*catch(UnknownHostException)
{
System.err.println("Don not know about 127.0.0.1");
}*/
catch(IOException e)
{
System.err.println("could not get I/O for the connection to:127.0.0.1");
}

if(MoreThread!=null&&os!=null&&is!=null)
{
Socket s = new Socket(host,port);
             System.out.println("The port " + port + " is opened at " + host);
os.close();
is.close();
MoreThread.close();
}
}

}
提示说 8 12行找不到符号

解决方案 »

  1.   

    //给你一个.我以前写的
    import java.io.*;
    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){}
    }
    }
      

  2.   

    //你的改了一下!
    import java.io.*;
    import java.net.*;public class scanner
    {
    public static void main (String[] args)
    {
    System.out.println("Scanning……");
    for(int i=1;i<=5000;i++)
    {
    new MoreThread("www.163.com",i).start();
    }
    }
    }
    class MoreThread implements Runnable
    {
    Thread own;
    String host;
    int port;
    Socket MoreThread=null;
    DataOutputStream os=null;
    DataInputStream is=null;
    MoreThread(String host, int port)
    {
    own=new Thread(this);
    this.host=host;
    this.port=port;
    }
    public void start()
    {own.start();}public void run()
    {
    try
    {
    MoreThread=new Socket(host,port);
    System.out.println("端口:"+port+"开放");
    }
    catch(Exception e)
    {
    }if(MoreThread!=null&&os!=null&&is!=null)
    {
    try{
    Socket s = new Socket(host,port);
    System.out.println("The port " + port + " is opened at " + host);
    os.close();
    is.close();
    MoreThread.close();
    }catch(Exception e){System.out.println("关闭失败");}
    }
    }}