Q:

Java Port scanner

import java.net.Socket;
import java.io.IOException;

public class Main {

    public static void main(String[] args) {
       String remote = "69.163.44.171";
       int i = 0;
       do {
       try {
       Socket s = new Socket(remote,i);
       System.out.println("Server is listening on port " + i+ " of " + remote);
       s.close();

       } catch (IOException ex) {
       System.out.println("Server is not listening on port " + i+ " of " + remote);
    }
       i++;
       } while(i == 55000);
}

Output:
Server is not listening on port 0 of 69.163.44.171
BUILD SUCCESSFUL (total time: 0 seconds)

i use while loop cause it is faster, now to the question why does it only scan one port? 

A:

Well... how often did you think the condition while(i == 55000) would be true?

