title: Socket not returning NULL or \n for ReadLine()
body: <p>I've read up several articles and questions related to the readLine() hanging. I'm not sure if I can manually add a NULL at the end of the response from the server side (it's remote location). As far as I can tell, I probably can't control it. </p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
   &lt;Response&gt;
   &lt;Reply Status="OK" /&gt;
   &lt;Data attr="..." /&gt;    &lt;-- BufferedReader hangs after this is printed. 
   &lt;/Response&gt;    &lt;--- I'm assuming this has no "\n" or "null" so it keeps waiting 
                       till the socket closes
  </code></pre>
  
  <p>What can I do to fix this? I don't exactly need the last line but I don't want my code to keep having exceptions. I'm using Javascript and here is a portion of my code. </p>
  
  <pre><code> if (socketForXML &amp;&amp; socketForXML.isConnected()){
      socketForXML.setSoTimeout(60000);
      var command = new Packages.java.lang.String( theCommand );
  
      var os = socketForXML.getOutputStream();
      os.write( command.getBytes("UTF-8") );
      os.flush();
      log.info("sendXMLCommand - sent command : " + command);
  
      //RECEIVE RESPONSE FROM SERVER - in STRING format
      var inStream = socketForXML.getInputStream();
      var reader = new Packages.java.io.InputStreamReader(inStream, "UTF-8");
      var buffer = new Packages.java.io.BufferedReader( reader );
      while( ( line = buffer.readLine() ) != null ) {
          log.debug(line);
      }
      socketForXML.close();
  </code></pre>
  
  <p>}</p>
  
  <p>I've also tried using buffer.read() and it'll get me all the ASCII numbers for the /Response tag but after that last > it will hang as well. I tried doing a check with try catch but it will still wait until socket closes and nothing is ever returned :(.</p>
  
  <pre><code>try{
      if (buffer.read() &lt; 0 ){
        log.error("END OF FILE.");
      }
  catch(e) {
      log.error("did not work.");
  }
  </code></pre>