My write to the socket is not reset until the socket closes. How to change?

My fwrite to the socket is not cleared until the socket closes. How to change? I want it to wash off after every frit.

I tried:

1) flush ()
2) fflush ()
3) ob_implicit_flush (true);

None of those who worked, I still had to close php for my socket in order to get the data.


Including sample code, does everything look 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);
    }
+3
source share
1 answer

There is a function for this! fflush ($ rc)

Are you sure you have the correct resource as a parameter?

change

. , socket_ *. fsockopen, fwrite, fflush, fsockclose. , . . php.

+5

Source: https://habr.com/ru/post/1747281/


All Articles