cURL / Mailing Lists / curl-library / Single Mail

curl-library

Why is upload with curl slow?

From: Thorsten Schanno <thorsten.schanno_at_gmx.net>
Date: Mon, 08 Dec 2008 10:06:27 +0100

Hi all,

I wrote a little program, that uploads a file to a ftp-server. However if I use it, I have an upload speed of only 160 kb/sec. But this server is in our intranet. If I move a file via filezilla I get the full bandwidth of some Megabyte/sec.
If I do a multiperform with 2 files to upload, they are uploaded both with 160 kb/sec.

Can anyone explain me this? Is there perhaps an option I forgot to set?
My program looks like this:

static size_t
read_function(void *ptr, size_t size, size_t nmemb, void *stream) {

    FILE* stream_neu = (FILE*) stream;
    size_t retcode = fread(ptr, size, nmemb, stream_neu);

    //fprintf(stderr, "*** We read %d bytes from file\n", retcode);
    return retcode;
}

int main()
{

if (1) {

CURL *che;
che = curl_easy_init();
CURLcode res = CURLE_OK;

FILE *file = fopen("anyfile.txt","rb");
if ( file == NULL ) {
    printf("You failed! File error while opening!\n");
    return -1;
}

if (che) {

    /* Die read-Funktion angeben */
    curl_easy_setopt(che, CURLOPT_READFUNCTION, read_function);
   

    /* Wir wollen einen Upload */
    curl_easy_setopt(che, CURLOPT_UPLOAD, 1L);
    
    /* URL mit BN und PW angeben */
    std::string url="";
    url.append("ftp://");
    url.append("username");
    url.append(":");
    url.append("password");
    url.append("@");
    url.append("somewhere.com");
    url.append("/path/");
    url.append("anyfile.txt");

 
    curl_easy_setopt(che, CURLOPT_URL, url.c_str());
 

    /* Datei, die hochgeladen werden soll */
    curl_easy_setopt(che, CURLOPT_READDATA, file);

    /* Verbose Modus anschalten */
    curl_easy_setopt(che, CURLOPT_VERBOSE, 1L);

    curl_easy_setopt(che, CURLOPT_NOPROGRESS, 0);
 

    res = curl_easy_perform(che);

    curl_easy_cleanup(che);
   

    curl_global_cleanup();

    fclose(file);
}

}

-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger
Received on 2008-12-08