vickzhu

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  151 随笔 :: 0 文章 :: 34 评论 :: 0 Trackbacks

public class VickTest {
 public static void main(String[] args) throws InterruptedException {

  for (int i = 0; i <= 65535; i++) {
   MyTask mt=new MyTask(i);
   Thread thread=new Thread(mt);
   thread.start();
   if(i%100==0){
    Thread.sleep(500);
   }
  }
 }

}

class MyTask implements Runnable{
 int port;
 public MyTask(int port) {
  this.port = port;
 }

 public void run() {
  try {
   Socket s=new Socket("203.208.35.100",port);
   System.out.println("端口"+port+"绑定成功!");
  } catch (UnknownHostException e) {
   System.out.println("主机不明");
  } catch (IOException e) {
   System.out.println("端口"+port+"绑定失败.");
  }
 }
}

posted on 2008-11-19 15:19 筱 筱 阅读(255) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: