title: Do I have to write to the socket to have the server send me a response to read from to grab banner for certain services?
body: <pre><code>public class PortScan 
  {
  
  public String ip;
  
  public PortScan(String ip)
  {
      this.ip = ip;
  }
  public void setIP( String ip )
  {
      this.ip = ip;   
  }
  
  public String getIP()
  {
      return this.ip;
  }
  public void scan()
  {
      int i = 1;
      String ip = this.getIP();
      while(i &lt; 50000)
      {
      try
      {
          Socket sock = new Socket(ip, i);
          InputStream in = sock.getInputStream();
          OutputStream out = sock.getOutputStream();
          BufferedInputStream bins = new BufferedInputStream(in);
          BufferedReader bin = new BufferedReader(new InputStreamReader(bins));
          String response = bin.readLine();
          System.out.println(response);
          System.out.println(ip + ":" + i);
          sock.close();
      }
      catch( UnknownHostException e )
      {
  
          //System.out.println("No host found.");
      }
      catch(IOException e)
      {
  
          //System.out.println("Problem connection to host.");
      }
      i++;
      }
  } 
  public static void main(String[] args) 
  {
      PortScan aPortScan = new PortScan("127.1.1.1");
  
      aPortScan.scan();
  }
  }
  </code></pre>
  
  <p>Console Output:</p>
  
  <pre><code>SSH-2.0-OpenSSH_6.0p1 Debian-4
  127.1.1.1:22&lt;
  null
  127.1.1.1:80
  </code></pre>