Using libcurl with libevent
Asked Answered
C

2

7

Can anyone show (through code) or explain to me how I might use libevent and curl together in a c program? I'm trying to write a high-performance non-blocking data monitor which needs to upload data to a CouchDB instance. I'm familiar with both libevent and curl, but merging curl_multi with libevent has me stumped for some reason. I do not understand the program flow of the offical libcurl example - can anyone point me to, or supply, a simpler example?

Cancellate answered 3/8, 2011 at 14:2 Comment(0)
P
8

The key is really the curl_multi_socket_action() function that should be used as soon as your event library says there's something on a socket to deal with. Event-based libcurl is more complex than "plain" libcurl so doing a very easy example is not that straight forward.

Pentylenetetrazol answered 3/8, 2011 at 17:42 Comment(3)
when I call curl_multi_socket_action() telling it either to read or write, does it use the read/write callback functions that were set up using curl_easy_setopt()? If not, how does it perform the read/write?Cancellate
Yes, it will use the callbacks for reading/writing as you have setup.Pentylenetetrazol
Ah, alright, that make this a little clearer. Thanks for your help.Cancellate
T
0

One exotic way to use curl with libevent is in a coroutine.

Tu answered 14/4, 2022 at 7:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.