title: Sending messages from server to all clients
body: <p>I've created a chat program, but I can't figure out one little aspect. The way it works now is like this:</p>
  
  <p>Server starts</p>
  
  <p>Client 1 connects</p>
  
  <p>Client 2 connects</p>
  
  <p>Client 1 sends message: hello.</p>
  
  <p>Server gets the message and sends it to all connected clients.</p>
  
  <p>The main problem I'm having is the server sends Client 1's message to Client 1 as well so there's now 2 "hello"'s instead of just 1.</p>
  
  <p>Here's my Server.java</p>
  
  <pre><code>for (Iterator&lt;DataOutputStream&gt; e = clients.iterator(); e.hasNext(); ) {
        DataOutputStream dout = (DataOutputStream)e.next();
  
        dout.writeUTF(message);
   }
  </code></pre>