cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: post data in a chunk to http server and also receive data from there to a chunk

From: Jeff Pohlmeyer <yetanothergeek_at_yahoo.com>
Date: Fri, 12 Sep 2003 21:58:06 -0700 (PDT)

> > is it expensive?
> libcurl is free ;-)

Sorry, I was trying to be funny. (I guess comedy is not my strong suit)

The point is, "expensive" is such a relative term. Compared to what?

Compared to a hand-optimized assembler routine?
Probably yes.
Compared to performing the same operation via MSIE/ActiveX/COM?
Probably not.

If you ask me if a new Porsche is expensive, I would say yes.
If you asked Bill Gates the same question, you might get a different answer!

( On a 286 with 540k of ram, "wordstar" was rather expensive. )

> Then I can manipulate the data via A.

> - is it doable? or I have to "copy" the data into my buffer? how long does
> the data would be "alive"? when the data would be deleted?
> - Furthermore, who needs to delete the data? curl would do it?

Normally, the last parameter to the write callback (void *data) would be a
pointer to a file stream that your application assigns via CURLOPT_WRITEDATA
in curl_easy_setopt.

From there, you can do as you please with the data received from the ptr parameter.
libcurl will take care the of the memory for the ptr itself, but if you allocate
a buffer to copy the ptr into, then (obviously) your program is responsible to free
the memory for that buffer.

> setBufSize(size);
This should probably be:
  setBufSize(size * nmemb);

Also note that the callback should return (size*nmemb) in order to continue.
  
Although CURLOPT_WRITEDATA is normally a file stream, it can be a pointer
to anything you like. My "tCurl" interface for Delphi actually passes a
pointer to the class instance here, so that I can use the same callback
for several tCurl objects, and the callback will "know" which instance
to act on.

It sounds like you may be trying to digest a little too much at one time.

I would suggest writing a few simple programs to get familiar with libcurl,
before you dive into using it with C++ objects, multi-threading, etc...

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-09-13