By Default stream_get_contents
waits and listen for 60 seconds.
if i have multiple streams and want to listen all of them continuously.
Inside foreach if i am listening one stream, i can't listen other ones.
What is the solution to listen and capture stream output for all streams continuously?
while(true){
//$streamArray is an array of streams obtained by stream_socket_client("tcp://..);
foreach($streamArray as $stream){
fputs($stream,$command);
stream_get_contents($stream); // and update file/DB (Blocking call)
}
}
Note: For every stream i have already done stream_set_blocking( $stream , true );
Update:
My requirement is to listen all streams for some time say 30 mints. at the same time i can't listen 2 stream. if i have 5 streams, my code is just time division multiplexing
, out of 30 mints each individual stream will be recorded only for 6 mints
I have one solution that make AJAX request for individual stream and record independently. Certainly i don't want to do this multiple AJAX call method as it will result in more code as well as more CPU.