title: Test if remote port is in use
body: <p>I have the need to discover open ports on a remote server. I'm wondering if this is possible. I was thinking I'd open a socket, and if this succeeds, it means that it's used ... otherwise, if I get an exception, then it is not used. </p>
  
  <p>For example,</p>
  
  <pre><code>public boolean isActive() {
      Socket s = null;
      try {
          s = new Socket();
          s.setReuseAddress(true);
          SocketAddress sa = new InetSocketAddress(this.host, this.port);
          s.connect(sa, 3000);
          return true;
      } catch (IOException e) {
          e.printStackTrace();
      } finally {
          if (s != null) {
              try {
                  s.close();
              } catch (IOException e) {
              }
          }
      }
      return false;
  }
  </code></pre>
  
  <p>is this a viable approach?</p>