title: Why URI on browser causes socket to run thrice
body: <p>This is a simple chat server.
  If I run and type : localhost:9092, I get the print statements printing three times each.
  I expected them to only print once.
  Can someone explain why a just typeing localhost:9092 only once causes while loop to run thrice ?</p>
  
  <pre><code>public class ChatServer {
  
      public static void main(String[] args) throws IOException, InterruptedException {
          ServerSocket serverSocket = null;
          Socket socket = null;
          PrintWriter pw = null;
  
          try {
              serverSocket = new ServerSocket(9092);
              while (true) {
                  socket = serverSocket.accept();
                  System.out.println("--- socket properties: " +  socket.getPort());
                  pw = new PrintWriter(socket.getOutputStream(), true);
                  pw.println("&lt;font size=\"3\" color=\"red\"&gt;This is sme text!&lt;/font&gt;");
                  pw.println("&lt;font size=\"3\" color=\"green\"&gt;This is some text!&lt;/font&gt;");
                  pw.close();
                  socket.close();
                  System.out.println("----- someone entered.");
              }
          } finally {
              if (serverSocket != null)
              serverSocket.close();
          }
      }
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>--- socket properties: 61802
  ----- someone entered.
  --- socket properties: 61803
  ----- someone entered.
  --- socket properties: 61804
  ----- someone entered.
  </code></pre>