Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

libcurl Basics 1

Status
Not open for further replies.

AbidingDude

Programmer
Oct 7, 2012
74
US
I'm just beginning to learn libcurl. I'm a little confused on the callback function parts - both for CURLOP_WRITEFUNCTION and CURLOPT_READFUNCTION.
The help file (for READFUNCTION) says:
"...The data area pointed at by the pointer buffer should be filled up with at most size multiplied with nitems number of bytes by your function. size is always 1."
It almost makes it sound like I have to provide 'buffer' and 'nitems', but it seems like I never call the function directly. It's passed to other libcurl functions, so libcurl provides these parameters?
I understand that I would have to write a function to handle where we are in the data stream, but it sounds like I don't have to establish a buffer or buffer size?
 
These seems to be working examples for:
CURLOPT_WRITEFUNCTION:

CURLOPT_READFUNCTION:
as you can see inside of the function read_callback() data are copied into location pointed by *buffer - in the example it's named *dest.

To fully understand the matter, I recommend trying to compile and debug the demo programs.
 
Status
Not open for further replies.

Similar threads

Replies
4
Views
258

Part and Inventory Search

Sponsor

Back
Top