I have a PHP socket client which transfer a image (BMP) to the socket server
$host="127.0.0.1" ;
$port=8000;
$timeout=30;
$socket=fsockopen($host,$port,$errnum,$errstr,$timeout) ;
$bmp=file_get_contents("C:/Image.bmp");
$bytesWritten = fwrite($socket, $bmp);
fclose($socket);
The transferred image is always corrupted and halfly streamed and giving the error message
Fatal error: Maximum execution time of 60 seconds exceeded
im transferring from localhost to localhost 😉 and i have a ASP.NET app which does the same thing in milliseconds ! so why not PHP? why it takes long time ?
i think there is some thing to do with file_get_contents which creates a large BLOB behalf of that is there a way to use a FileStream in PHP ?
any idea how to transfer the file without corrupting ?
file_get_contentsreturns a string. I think you want to usefreadinstead.Example: