Client not able to receive messages from Server Socket programming Java
<p>I am trying to make a chat system through terminal. One computer acts as server, the other as client.</p>

<p>Here is my code for Client side :</p>

<pre><code>try
    (
        Socket s = new Socket(hostname,port);
        PrintWriter out = new PrintWriter(s.getOutputStream(),true);
        BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
        BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
    ) {
        String input;

        while ((input = stdIn.readLine()) != null)
        {
            out.println(input);
        }


        String inputline;
        while ((inputline = in.readLine()) != null)
        {
            System.out.println("Them: " + inputline);
        }



        // out.close();
        // stdIn.close();
        // s.close();
    }
    catch (UnknownHostException e)
    {
        System.err.println("Don't know about host: " + hostname);
        System.exit(1);
    }
    catch (IOException e)
    {
        System.err.println("Couldn't get I/O");
        System.exit(1);
    }
</code></pre>

<p>Here is my code for Server side:</p>

<pre><code>System.out.println ("New communication thread started.");
        try
        {
            PrintWriter out = new PrintWriter(clientSocket.getOutputStream(),true);
            BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));

            BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
            String input;

            String inputline;
            while ((inputline = in.readLine()) != null)
            {
                System.out.println("Them: " + inputline);
            }

            while ((input = stdIn.readLine()) != null)
            {
                out.println(input);
            }
        }
        catch (IOException exx)
        {
            System.err.println("Some problem");
            System.exit(1);
        }
</code></pre>