Re: Download speed limit
| From: | clive | Date: | Fri, 18 May 2007 06:31:38 +0000 |
| Subject: | Re: Download speed limit | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-255109@lists.php.net to get a copy of this message | ||
Rangel Reale wrote:
Yes, I tried, this works, but I would like to control the send speed more, preferably via URL, as this programs will only be accessed by my desktop application, and I have full control of them.ok if its only your application thats going to use this data, you could 1. setup a ftp server that does bandwidth limiting. Then your application downloads the file via ftp. 2. rsync has a bandwidth limiting option aswell.
But, if there is no other way, this will be the way! ----- Original Message ----- From: "Greg Donald" <gdonald@gmail.com> To: <php-general@lists.php.net> Sent: Thursday, May 17, 2007 6:55 PM Subject: Re: [PHP] Download speed limit-- Regards, Clive. Real Time Travel Connections {No electrons were harmed in the creation, transmission or reading of this email. However, many were excited and some may well have enjoyed the experience.}On 5/17/07, Rangel Reale <listas@rangelreale.com> wrote:Hmm that apache module isn't quite what I need, it just accepts or refuse connections based on bandwidth usage, it does not throttle the connection.Have you tried something like this? <?php $file = '/opt/local/apache2/htdocs/test_file.txt'; set_time_limit( 0 ); $handle = fopen( $file, 'rb' ); if( !$handle ) { die( 'fopen() failed' ); } header( 'Content-Type: text/plain' ); header( 'Content-Length: ' . filesize( $handle ) ); header('Content-Disposition: attachment; filename="' . basename( $file ) . '"' ); while( ( !feof( $handle ) ) && ( connection_status() == 0 ) ) { print( fread( $handle, 1024 * 8 ) ); sleep( 1 ); flush(); } fclose( $handle ); I get right at 8K/sec using that. -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.467 / Virus Database: 269.7.0/803 - Release Date: 13/5/2007 12:17