package com.huaming; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; import java.net.UnknownHostException; public class TestScanner { /** * @param args */ public static void main(String[] args) { new TestScanner().launcher(); } public void launcher() { for (int i = 1; i < 65536; i++) { try { Socket socket = new Socket(); socket.connect(new InetSocketAddress(InetAddress.getByName("xxx.xxx.xxx.xxx"), i), 20); //System.out.println(); System.out.println(i); socket.close(); } catch (UnknownHostException e) { //System.out.print("u"); } catch (IOException e) { //System.out.print("i"); } } } }