CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2015

    Java Port Scanner

    Port Scanner
    import java.net.*;
    import java.io.IOException;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
        public class PScanner {
             public static void main(String[] args) {
             InetAddress ia=null;
             String host=null;
                 try {
                 host=JOptionPane.showInputDialog("Enter the Host name to scan:\n example: xxx.com");
                     ia = InetAddress.getByName(host);
                 scan(ia); }
                 catch (UnknownHostException e) {
                 System.err.println(e );
             System.out.println("Bye from NFS");
            public static void scan(final InetAddress remote) {
            //variables for menu bar
            int port=0;
            String hostname = remote.getHostName();
                 for ( port = 0; port < 65536; port++) {
                     try {
                     Socket s = new Socket(remote,port);
                     System.out.println("Server is listening on port " + port+ " of " + hostname);
                     catch (IOException ex) {
                     // The remote host is not listening on this port
                     System.out.println("Server is not listening on port " + port+ " of " + hostname);
             }//for ends
    Java Port Scanner

  2. #2
    Join Date
    Jul 2016
    Walnut, California United States

    Re: Java Port Scanner

    A port scanner is a software application designed to probe a server or host for open ports. This is often used by administrators to verify security policies of their networks and by attackers to identify running services on a host with the view to compromise it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.