My php script downloads files from a remote server using cURL. I wanted to monitor the bandwidth that was being used when downloading the file so what I did was put an SQL update query within the write_callback function. This works like a charm but im worried that the database will have troubles if a script like this is updating data every 10 miliseconds or so. Does cURL have a “completed” call back function? so that the script will collect the amount of bytes that were downloaded then update ONLY once when its been completed? And also does the cURL have some type of interruption callback or incomplete? so when users kill the download it somehow recognizes that and subtracts the bytes that were downloaded in the process.
Share
You could do something like this:
Handling interupts would be more difficult, but maybe you could use
register_shutdown_function()? I don’t know if this actually gets called when the script receives SIGINT, though. You may also be able to usepcntl_signal()if it is available.