title: ServerSocket vs Socket -- closing the socket
body: <p>Both <a href="http://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html#close%28%29" rel="nofollow">ServerSocket</a> and <a href="http://docs.oracle.com/javase/7/docs/api/java/net/Socket.html#close%28%29" rel="nofollow">Socket</a> have the method <code>close()</code> to close the socket. </p>
  
  <p>What is the difference between the two?</p>
  
  <p>Suppose, on the server side, </p>
  
  <pre><code>ServerSocket serverSocket = new ServerSocket(port);
  Socket socket = serverSocket.accept();  
  ...
  </code></pre>
  
  <p>In this case, how is </p>
  
  <pre><code>socket.close();
  </code></pre>
  
  <p>different from </p>
  
  <pre><code>serverSocket.close();
  </code></pre>
  
  <p>if any?</p>
  
  <p>TIA.</p>