das folgende programm bleibt ständig bei "write data to encoder..." stehen, obwohl select versichert haben sollte, dass das nicht passieren kann...
hat jemand ne idee, woran das liegen könnte?
hat jemand ne idee, woran das liegen könnte?
PHP:
$read = array();
#adding read fd if we need data
if( sizeof( $buffer_input ) < 1024 )
$read[] = $input;
if( sizeof( $buffer_output ) < 1024 )
$read[] = $mencoder[ 'output' ];
# adding write fd if we have data
$write = array();
if( sizeof( $buffer_output ) )
$write[] = $client;
if( sizeof( $buffer_input ) )
$write[] = $mencoder[ 'input' ];
#select
$rc = stream_select( $read, $write, $ex = NULL, 5, 0 );
if( $rc === false ) {
echo "error doing select\n";
break;
}
if( $rc === 0 ) {
echo "no data in 5 seconds, try again";
$error++;
continue;
}
$error = 0;
if( in_array( $input, $read ) ) {
echo "read input from source...\n";
$buffer_input[] = fread( $input, 4096 );
}
if( in_array( $mencoder[ 'output' ], $read ) ) {
echo "read data from encoder...\n";
$buffer_output[] = fread( $mencoder[ 'output' ], 4096 );
}
if( in_array( $client, $write ) ) {
echo "write data to the client\n";
if( !fwrite( $client, array_shift( $buffer_output ) ) )
break;
fflush( $client );
}
if( in_array( $mencoder[ 'input' ], $write ) ) {
echo "write data to encoder...\n";
if( !fwrite( $mencoder[ 'input' ], array_shift( $buffer_input ) ) )
break;
fflush( $mencoder[ 'input' ] );
}