title: PHP hanging on socket_read
body: <p>I am trying to read a response from a socket I have written on a Java application. However the PHP is just hanging. Here is the code I am using to read from the socket:</p>
  
  <pre><code>while($resp = socket_read($socket, 1000)) {
     $str .= $resp;
     if (strpos($str, "\n") !== false) {
          break;
     }
  }
  </code></pre>
  
  <p>When I run the socket call from terminal there is deffinately a response. This is what my response code is in Java:</p>
  
  <pre><code>out.println(request.seed);
  </code></pre>
  
  <p>Where request.seed is an int. I have also tried:</p>
  
  <pre><code>out.println(request.passcode + "\n");
  </code></pre>
  
  <p>But this didnt fix the problem.</p>
  
  <hr>
  
  <p>When I request the following in terminal:</p>
  
  <pre><code>josephs-macbook:~ jf$ echo "pairBankRequest|userID=305,bankID=12," | nc 127.0.0.1 3030
  </code></pre>
  
  <p>I get the following reply:</p>
  
  <pre><code>830039
  </code></pre>
  
  <p>which is what is expected.</p>