JWood
JWood

Reputation: 2834

C++ library for dealing with multiple HTTP connections

I'm looking for a library to deal with multiple simultaneous HTTP connections (pref. on a single thread) to use in C++ in Windows so it can be Win32 API based. This is for a client application that must process a list of requests but keep 4 running at all times until the list is complete.

So far, I have tried cURL (multi interface) which seems to be the most appropriate that I have found but my problem is that I may have a queue of 200 requests but I need to only run 4 of them at a time. This becomes problematic when one request may take 2 seconds and another may take 2 mins as you have to wait on all handles and receive the result of all requests in one block. If anyone knows a way round this it would be very useful.

I have also tried rolling my own using WinHTTP but I need to throttle the requests so they would ideally need to be on a single thread and use callbacks for data which WinHTTP does not do.

The best thing I've found which would solve all my problems is ASIHTTPRequest but unfortunately it's Mac OSX only.

Thanks, J

Upvotes: 4

Views: 1007

Answers (4)

Daniel Stenberg
Daniel Stenberg

Reputation: 58184

libcurl's multi interface supports exactly what you're asking for.

Upvotes: 0

Eugen Constantin Dinca
Eugen Constantin Dinca

Reputation: 9150

Asio is a great library but it's generic, the HTTP examples are just that: examples, there's no support for redirection, authentication and so on.
I know of two libraries built on top of Boost & Asio that support the HTTP protocol: cpp-netlib and Pion Network Library but AFAIK neither directly supports what you want.
All that being said if you're comfortable with using libcurl it should be pretty easy to use the "easy" interface with callbacks and implement the requests queue yourself.

Upvotes: 0

bratao
bratao

Reputation: 2080

Did you tried Boost Asio ? Is multiplataform and stellar performance, and with nice examples of HTTP.

http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio.html

Upvotes: 2

Tom
Tom

Reputation: 5309

Have you looked at boost.asio? http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio.html

Its meant to scale well and has http server examples: http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/examples.html

Upvotes: 3

Related Questions