Re: Re: Download speed limit

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

 



On 5/18/07, Rangel Reale <listas@xxxxxxxxxxxxxxx> wrote:

----- Original Message -----
From: "Tijnema !" <tijnema@xxxxxxxxx>
To: "Jonathan" <haptiK@xxxxxxxxx>
Cc: <php-general@xxxxxxxxxxxxx>
Sent: Friday, May 18, 2007 12:07 PM
Subject: Re:  Re: Download speed limit


> On 5/18/07, Jonathan <haptiK@xxxxxxxxx> wrote:
>> Rangel Reale wrote:
>> > Hello!
>> >
>> > For my application I need to limit the speed that my application sends
>> > data, in my case a binary file.
>> >
>> > I need to send the speed as a parameter, like:
>> >
>> > sendfile.php?speed=20000
>> >
>> > Would send the file at 20kb/s (forgetting about real byte counts for
>> > this example).
>> >
>> > To send the file, I am doing:
>> >
>> >     $fp=fopen($this->contentfile,"rb");
>> >     while(!feof($fp)){
>> >         print(fread($fp,1024*8));
>> >         flush();
>> >         ob_flush();
>> >     }
>> >     fclose($fp);
>> >
>> > If after ob_flush I do a sleep(), I can limit the speed, but I would
>> > like to limit at the speed of the parameter.
>> >
>> > Is there a way to do this?
>> >
>> > Thanks,
>> > Rangel
>> >
>>
>> Will this mean i can set my ?speed=99999999999999999999999999999999
>>
>> Excellent!
>>
>
> Yeah, that's nice, you limit it, but a little bit smart guy can set it
> to whatever he/she wants :)
>
> Tijnema
>
Hehehe yes, but as I said in a later message, only my application will be
accessing this page (hopefully), and the problem is not on the sending
server (which has lots of bandwidth) but on the receiving client, where my
downloading is killing all its small bandwidth.

Ok, then there's not a real problem, but to get to your problem, you
could simple tell the script how many data to send per loop, and since
you're sleeping 1 second each loop, should this amount be the same as
the amount specified on the command line.

so, this should work the way you want
  $sleep = $_GET['sleep'];
  $fp=fopen($this->contentfile,"rb");
  while(!feof($fp)){
      print(fread($fp,1024*$speed));
      flush();
      ob_flush();
      sleep(1);
  }
  fclose($fp);

Tijnema

> --
> 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
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
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