I am using PHP to connect to a local C++ socket server to keep state between a web app and a couple of daemons.  I can send data to the socket server, but not receive from it; it just blocks on socket_read() and hangs indefinitely.  Am I forgetting something dumb (like a NULL character or a different combination of newline characters)?  The PHP is below:
socket_connect($sock, $addr, $port); 
socket_write($sock, 'Hello world');
$str = '';
while($resp = socket_read($sock, 1000))
    $str .= $resp;
socket_close($sock);
die("Server said: {$str}");
The related part of the socket server is below (note that the << and >> operators are overloaded):
std::string data;
sock >> data;
sock << data << std::endl;
Where >> calls Socket::recv(std::string&) and >> calls Socket::send(const std::string&).
This works fine from (for example) telnet, but PHP doesn't want to play nice. Any thoughts/suggestions are appreciated.