title: Java TCP - server & client working, but can't get answer
body: <p>I'm trying to make a small TCP server/client thingy. I have a client and a server, and after getting some basic Exceptions solved, nothing works.
  The client is supposed to send (user) data to the server (at port 6789, localhost), who is then supposed to write it in uppercase and end it back. Everything seems to work, except for sending back the uppercase. Here is the code:</p>
  
  <p>TCPServer:</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.DataOutputStream;
  import java.io.InputStreamReader;
  import java.net.ServerSocket;
  import java.net.Socket;
  
  public class TCPServer {
  
      public static void main(String[] args) throws Exception {
  
          System.out.println("SERVER");
  
          String clientSentence;
          String capitalizedSentence;
          ServerSocket server = new ServerSocket(6789);
  
  
          TCPClient.main(null);
  
  
          while (true) {
              Socket connection = server.accept();
              System.out.println("&lt;S&gt; Connection!");
              BufferedReader fromClient = new BufferedReader(
                  new InputStreamReader(connection.getInputStream()) );
              DataOutputStream toClient = new DataOutputStream(connection.getOutputStream());
  
              clientSentence = fromClient.readLine();
              System.out.println("&lt;S&gt; Recieved: " + clientSentence);
  
              capitalizedSentence = clientSentence.toUpperCase() + '\n';
              System.out.print("About to send: " + capitalizedSentence);
              toClient.writeBytes(capitalizedSentence);
          }
      }
  
  }
  </code></pre>
  
  <p>TCPClient:</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.DataOutputStream;
  import java.io.InputStreamReader;
  import java.net.Socket;
  
  public class TCPClient {
  
      public static void main(String[] args) throws Exception {
  
          System.out.println("CLIENT");
  
          String sentence;
          String modSentence;
          BufferedReader inUser = new BufferedReader(new InputStreamReader(System.in));
  
          Socket clientToServer = new Socket("localhost", 6789);
          DataOutputStream outServer = new DataOutputStream(clientToServer.getOutputStream());
          BufferedReader inServer = new BufferedReader(
              new InputStreamReader(clientToServer.getInputStream()) );
  
          System.out.println("&lt;C&gt; Type now: ");
          sentence = inUser.readLine();
          System.out.println("&lt;C&gt; Got it!");
  
          System.out.println("&lt;C&gt; Sending " + sentence + " to server...");
          outServer.writeBytes(sentence + '\n');
          outServer.flush();
  
          System.out.println("&lt;C&gt; Server respodse:");
          modSentence = inServer.readLine();
  
          System.out.println("&lt;C&gt; From server: " + modSentence);
          clientToServer.close();
      }
  }
  </code></pre>
  
  <p>Console:</p>
  
  <pre><code>SERVER
  CLIENT
  &lt;C&gt; Type now: 
  efd
  &lt;C&gt; Got it!
  &lt;C&gt; Sending efd to server...
  &lt;C&gt; Server respodse:
  asd
  </code></pre>
  
  <p>and...</p>
  
  <p>Nothing</p>