Hello,
I have the following code in a server portion of a PHP program:
function getFile( $socket, $file ){
$data = "";
while( ( ( $buf = @socket_read( $socket, 1, PHP_NORMAL_READ ) ) !== false ) ){
$data .= $buf;
}
fputs( $file, $data );
}
And this above function is being written to by:
/*
* Sends a file
*/
function sendFile( $file, $socket ){
/* send the file */
$fp = fopen( $file, 'rb' );
while( !feof( $fp ) ){
$line = fgets( $fp, 512 );
socket_write( $socket, $line, strlen( $line ) );
}
$data = "\n";
socket_write( $socket, $data, strlen( $data ) );
}
In this first instance, it works perfectly - I need however to read in a binary safe manner, and hence I need to use PHP_BINARY_READ in the first extract - it however doesn't work... I don't know what the problem might be - is it socket_write that is no good? I have also tried sending the trailing \n as \0 under binary_read and still no deal.
Experience required...and appreciated.
Alex