Re: Download speed limit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/17/07, Rangel Reale <listas@xxxxxxxxxxxxxxx> 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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux