cURL / Mailing Lists / curl-library / Single Mail

curl-library

CURLOPT_MAX_RECV_SPEED_LARGE not working

From: Joaquim Pedro França Simão <osmano807_at_gmail.com>
Date: Wed, 13 May 2009 15:43:43 -0300

I am making a program that need to limit the speed of download, but I
do CURLOPT_MAX_RECV_SPEED_LARGE right and does not work! Look at my
code:

#include <stdio.h>
#include <iostream.h>
#include <curl/curl.h>

using namespace std;

int download(string url_download, string file, int down_speed)
{
  CURL *image;
  CURLcode imgresult;
  FILE *fp;
  //url_download.c_str();

    image = curl_easy_init();
        if( image )
         {
                //Open File
                fp = fopen(file.c_str(), "w");
                if( fp == NULL ) cout << "File cannot be opened";
                
                curl_easy_setopt(image, CURLOPT_WRITEFUNCTION, NULL);
                curl_easy_setopt(image, CURLOPT_WRITEDATA, fp);
                curl_easy_setopt(image, CURLOPT_URL, url_download.c_str());
                curl_easy_setopt(image, CURLOPT_FOLLOWLOCATION, 1);
                curl_easy_setopt(image, CURLOPT_MAX_RECV_SPEED_LARGE, 10);
                curl_easy_setopt(image, CURLOPT_NOPROGRESS, 0);
                //CURLOPT_RESUME_FROM
                
                // Grab image
                imgresult = curl_easy_perform(image);
                if( imgresult )
                        {
                                cout << "Cannot grab the File!\n";
                        }
        }
        //Clean up the resources
        curl_easy_cleanup(image);
        //Close the file
        fclose(fp);
        return 0;
}

//int ckeck_file_size (string url_download, string file
//CURLINFO_CONTENT_LENGTH_DOWNLOAD
Received on 2009-05-13