title: the ReadLine doesnt wait for input
body: <p>I have a socket client sending text to a socket server but the ReadLine doesnt seem to wait to receive a line before proceeding. Here is the of the server receiving the text:</p>
  
  <pre><code>public void run() {
  
          try {
  
              serveurSocket = new ServerSocket(PORT_ID);  
              connexionSocket = serveurSocket.accept();
  
  
              BufferedReader reader = new BufferedReader(new InputStreamReader(connexionSocket.getInputStream()));
              PrintWriter writer = new PrintWriter(connexionSocket.getOutputStream(), true);
  
              messageRecu = "";
              while (true) {
                  messageRecu = reader.readLine();
                  messageRecu = messageRecu.toUpperCase();
                  writer.println(messageRecu);
              }
  
              //reader.close();
              //writer.close();
  
  
          } catch (IOException e) {
              System.out.println(e.getMessage());
              e.printStackTrace();
          }
  
      }
  </code></pre>
  
  <p>After establishing the socket between client and server, the execution halts at reader.readLine until I send manually a string thru the socket. Which is normal and wanted. Codes resumes and its fine until its loops back to reader.ReadLine() where it will read a "null" line instead of waiting for input from the socket like it did the first time... this will obviously mess up the next command to uppercase. So how can I fix this?</p>
  
  <p>EDIT: I'll add the client side if that can help understand.</p>
  
  <pre><code>public class ClientSocket {
  
      private Socket clientSocket;
  
      public boolean isClosed() { return clientSocket.isClosed(); }
  
      public boolean connectToSocket (String ip, int port) {
  
          try {
              clientSocket = new Socket(ip, port);
              return true;
              } 
          catch (IOException e) { 
              System.out.println(e); 
              return false;
          }
  
      }
  
      public String sendToServer(String messageClient) {
  
          String messageRecu = "";
  
          try {
  
              BufferedReader reader = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
              PrintWriter writer = new PrintWriter(clientSocket.getOutputStream(), true);
  
              writer.println(messageClient);
              messageRecu = reader.readLine();
  
              reader.close();
              writer.close();
  
              return messageRecu;
  
          } 
          catch (IOException e) {
  
              System.out.println(e.getMessage());
              e.printStackTrace();
  
              return messageRecu;
  
          }
  
      }
  
  }
  </code></pre>
  
  <p>A button press will call "connectTosocket" to initiate the socket. A second button when pressed will send the content of a textfield using "sendToServer".</p>
  
  <p>Server does receive the message and return it capitalized but I wish for the socket to remain open with the server and if I send an other string for the same sequence to happen. Not even sure it can be done :(</p>