My fwrite to a socket is not flushed, until the socket closes. How to change? I want it to flush after each fwrite.
I've tried:
1) flush()
2) fflush()
3) ob_implicit_flush(true);
None of those worked, I still had to quit php for my socket to receive the data.
Including some sample code, anything looks wrong?
while($clientSocket = socket_accept($this->serviceConnection))
{
while( $clientMessage = socket_read($clientSocket, 1024) )
{
echo 'Relaying message to server: ' . $clientMessage;
if( !fwrite($this->Connection, $clientMessage) )
echo 'Error writing to server';
fflush($this->Connection);
}
socket_close($clientSocket);
}