title: Java Chat application for Command line is not sending or receiving messages
body: <p>Hi I am trying to create chat application thru socket Programming .</p>
  
  <p>However i am not able to send a message or receive it on either client or Server side.
  Only the System.out.println statement are shown as output.I am placing the code for the same.</p>
  
  <p>Server:</p>
  
  <pre><code>  import java.net.*;
      import java.io.*;
  
  
  class MyServer
  {
    public static void main(String arr[])
      {
      try
  
          {
          ServerSocket server=new ServerSocket(2500);//the server is listening to at this port
          System.out.println("Server is ready , waiting for a connection request...");
  
  
  
  /*Now the accept() method blocks while it is waiting for a client Socket connection.When a client finally tries to connect, the method returns a plain old Socket (on a 
  
  diffrent port) that knows how to communicate with the client(i.e. knwos the client IP address and port number).The SOcket is on a different port than the ServerSocket, 
  
  so that the ServerSocket can go back to waiting for other clients.*/
  
  
  
          Socket sock=server.accept();
          System.out.println("Request received , connection completed...");
          Thread.sleep(10000);
          System.out.println("Waiitng for message...");
          BufferedReader b=new BufferedReader(new InputStreamReader(sock.getInputStream()));
          String msg=b.readLine();
          System.out.println("Received message "+msg);
          Thread.sleep(10000);
  
          System.out.println("Sending acknowledgement");
          PrintStream out=new PrintStream(sock.getOutputStream());
          Thread.sleep(30000);
          out.println("Hello client, your test message is received");
          System.out.println("Ack sent, clsoing connection");
          Thread.sleep(50000);
          server.close();
          sock.close();
  
          System.out.println("Connection closed");
          }
          catch(Exception ex)
          {
  
          System.out.println(ex);
          }
  
      }
  
  }
  </code></pre>
  
  <p>The client:</p>
  
  <pre><code>  import java.net.*;
      import java.io.*;
  
  
     class MyClient
      {
    public static void main(String arr[])
      {
      try
  
          {
  
          System.out.println("Client ready , sending request...");
          Thread.sleep(10000);
          Socket socket=new Socket("localhost",2500);;    
          Thread.sleep(10000);
          System.out.println("Connection completed , sending message");
          PrintStream out=new PrintStream(socket.getOutputStream());
          Thread.sleep(30000);
          out.println("Hello server, its a test message");
  
          BufferedReader b=new BufferedReader(new InputStreamReader(socket.getInputStream()));
          String msg=b.readLine();
          System.out.println("Ack message "+msg);
          Thread.sleep(10000);
  
  
          System.out.println("clsoing connection");
          Thread.sleep(50000);
          socket.close();
  
          System.out.println("Connection closed");
          }
          catch(Exception ex)
          {
  
          System.out.println(ex);
          }
  
      }
  
  }
  </code></pre>
  
  <p>The output:
  on client:</p>
  
  <pre><code>D:\java&gt;java MyClient
  Client ready , sending request...
  Connection completed , sending message
  Ack message Hello client, your test message
  clsoing connection
  Connection closed
  </code></pre>
  
  <p>On server:</p>
  
  <pre><code>D:\java&gt;java MyServer
  Server is ready , waiting for a connection request...
  Request received , connection completed...
  Waiitng for message...
  Received message Hello server, its a test message
  Sending acknowledgement
  Ack sent, clsoing connection
  Connection closed
  </code></pre>
  
  <p>I am not able to input thru KeyBoard</p>