High Port Scanner with Socket in Java

Description

The following code shows how to high Port Scanner with Socket.

Example


/*from  w  w w  .  ja  va2 s .  c  om*/
import java.net.InetAddress;
import java.net.Socket;

public class Main {

  public static void main(String[] args) {

    String host = "localhost";

    try {
      InetAddress theAddress = InetAddress.getByName(host);
      for (int i = 1024; i < 65536; i++) {
        Socket theSocket = new Socket(theAddress, i);
        System.out.println("There is a server on port " + i + " of " + host);
      }
    } catch (Exception ex) {
      System.err.println(ex);
    }

  }

}




















Home »
  Java Tutorial »
    Network »




NetworkInterface
URI
URL
HTTP
HTTP Read
IP
Socket
UDP
URL Encode