title: Simple Chat using socket connection
body: <p>I am trying to make a simple chat. I have a server that handles more clients. This is what i did until now : the connections , i can identify on my server which client is sending the message , but the problem is that on client i can't get full conversation like on the server .For example </p>
  
  <pre><code>Client_1  (writing)
  msg : hi
  
  Client_2 (writing)
  msg : hi from cl2
  
  results 
  
  Server :
  Client_1 : hi
  Client_2 : hi from cl2
  
  Client_1 
  Client_1 : hi
  
  Client_2 
  Client_2 :hi from cl2
  </code></pre>
  
  <p>I want to achieve that both clients have the same info as server has.</p>
  
  <pre><code>My Server Script :
  public class Server {
  
      public static void main(String[] args) throws IOException {
          ServerSocket server = new ServerSocket(1900);
          System.out.println("waiting");
          while (true) {
              Socket sock = server.accept();
              System.out.println("Client nou conectat !");
              ClientHandler cH = new ClientHandler(sock);
              cH.start();
          }
      }
  }
  
  class ClientHandler extends Thread {
      BufferedReader in;
      PrintWriter out;
  
      ClientHandler(Socket sock) throws IOException {
          out = new PrintWriter(new OutputStreamWriter(sock.getOutputStream()),
                  true);
          in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
      }
  
      public void run () {
              try {
                  out.println("Hello from server"); //hello message to client
          while (true) {
              String linie = in.readLine();
              if (linie==null)
                  return;
              System.out.println(linie); //message from client 
              out.println(linie);
          }
      }catch(Exception e) {e.printStackTrace();}
          }
  }
  </code></pre>
  
  <p>Client script</p>
  
  <pre><code>public class Client {
      public static void main(String[] args) throws Exception {
      //  String ip ="192.168.1.12";
          String ip ="localhost";
          Socket sock = new Socket(ip, 1900); // localhost daca ii pe
                                                          // acelasi pc serverul
                                                          // si clientul,altfel
                                                          // IPul
          PrintWriter out = new PrintWriter(new OutputStreamWriter(
                  sock.getOutputStream()), true);
          BufferedReader in = new BufferedReader(new InputStreamReader(
                  sock.getInputStream()));
          String linie = in.readLine();
          System.out.println("Server :" + linie);//meesage from server
          BufferedReader console = new BufferedReader(new InputStreamReader(
                  System.in));
  
          while (true) {
              linie = console.readLine();
              out.println("Client_1 :"+linie); // sending to server
              String linie2 =in.readLine();
              System.out.println(linie2); //resend message to client
          }
      }
  }
  </code></pre>
  
  <p>I hope i explained well my problem :D . Thanks in advice for all </p>