title: What is the correct way to wait for a client response in java?
body: <p>First off, if you helped me solve my problem with reading an undefined length HTTP response, I'd like to thank you. I took your advice and switched from HTTP responses to raw Java sockets. But I'm having a little problem with this too.</p>
  
  <p>The nature of a push server is to push things to the client as they are recieved (in my case the system uses a file labeled with the device id.) The problem is that with the KnockKnock example on the Java Tutorials, their code:</p>
  
  <pre><code>while ((inputLine = in.readLine()) != null) {...   
  </code></pre>
  
  <p>Waits for the client to send something before sending something itself. So I decided to use:</p>
  
  <pre><code>while (true) {
      if ((inputLine=in.readLine())==null) inputLine="";
      ...
  </code></pre>
  
  <p>If any of the input interpereters get this empty string, then they won't do anything.</p>
  
  <p><strong>My Question</strong> essentially is which one is better and, if it's the first one, how can I keep checking the file to send out what is required without spawning a thread?</p>