curl-library
curl vs. sftp
Date: Thu, 30 Sep 2010 10:47:19 +0000 (GMT)
Hi all,
I'm facing a jet strange problem. At the moment most of our applicatios are
using the libcurl (latest version: 7.21.1)
But now one of our customers came up and complained that retrieving a file via
the standart RedHat 4 sftp client would be much faster than our apps using the
curl library.
So I made a few tests and hacked a quick-and-dirty C prog and used the unix
"time" command to measure the download time.
Swiftly said: It took nearly 12 minutes to get 250 MB via curltest2 app while it
only took roughly 3 minutes with the sftp client.
Any ideas ?
here is the curltest2:
#include <stdio.h>
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
size_t my_fwrite(void *buffer, size_t size, size_t nmemb, FILE *stream)
{
static int first_time=1;
char outfilename[FILENAME_MAX] = "testfile.bin";
static FILE *outfile;
size_t written;
if (first_time)
{
first_time = 0;
outfile = fopen(outfilename,"wb");
if (outfile == NULL)
{
return -1;
}
fprintf(stderr,"The body is <%s>\n",outfilename);
}
written = fwrite(buffer,size,nmemb,outfile);
return written;
}
int main(void)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl)
{
curl_easy_setopt(curl,
CURLOPT_URL,"sftp://192.168.0.1/test/myTestfile.bin");
curl_easy_setopt(curl, CURLOPT_USERPWD, "bla:blub");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
if(CURLE_OK != res)
{
fprintf(stderr, "curl told us %d\n", res);
}
}
return 0;
}
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-09-30