title: How to close ServerSocket connection when catching IOException?
body: <p>Sorry for question, but I'm totally noob in Java. What is the best practice to execute <code>ServerSocket.close()</code> when caught <code>IOException</code> from <code>ServerSocket</code>? According to docs, <code>ServerSocket.close()</code> throws <code>IOException</code> and compiler asks us to catch it. What is the proper way to close connection on <code>IOException</code>?</p>
  
  <pre><code>try {
      server = new ServerSocket(this.getServerPort());
      while(true) {
          socket = server.accept();
          new Handler( socket );
      }
  } catch (IOException e) {
      if (server != null &amp;&amp; !server.isClosed()) {
          server.close(); //compiler do not allow me to do because I should catch IOExceoption from this method also...
      }
  }
  </code></pre>
  
  <p>Thank you!</p>