cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to limit rate with libcurl?

From: Jick Nan <jick.nan_at_gmail.com>
Date: Fri, 8 Dec 2006 08:11:18 +0000

Hello,

On 12/8/06, Dan Fandrich <dan_at_coneharvesters.com> wrote:
> On Fri, Dec 08, 2006 at 07:07:45AM +0000, Jick Nan wrote:
> >
> > Sorry, I attached a wrong file last time, this is the real curl.c.
>
> > curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, MAX_RATE);
> > curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, MAX_RATE);
> > curl_easy_setopt(curl, CURLOPT_MAX_SEND_SPEED_LARGE, MAX_RATE);
>
> You aren't passing the right type for any of these options. The buffer size
> must be a long, and the two speed types must be curl_off_t.

I changed to:

        curl_off_t limitrate=102400;
        [...]
        curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, (long)limitrate);
        curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, limitrate);
        curl_easy_setopt(curl, CURLOPT_MAX_SEND_SPEED_LARGE, limitrate);

But it still can't work corectly...

> The number you give is much larger than CURL_MAX_WRITE_SIZE and "it only
> makes sense to use this option if you want it smaller."

The limit rate can be changed, and may little than
16K(CURL_MAX_WRITE_SIZE), I think I need it. Thx for this.

>
> >>> Dan
>

-- 
"生活就是个缓慢受锤的过程,人一天天老下去,奢望也一天天消失,最后变得像挨了锤的牛一样。"
Received on 2006-12-08