Is there any C/C++ library similar to apache httpcomponents? - c++

are there any library similar to apache httpcomponents for c/c++ language?
Thanks in advance,
Dario.

I'm not sure how similar they are to those particular Apache components, but you might want to look at POCO and ACE. Both provide quite a bit in the way of networking in C++. ACE tends to be the more all-encompassing of the two (both in terms of supporting lots of protocols and such, and in terms of tending to control/dominate all of how an application is written/works).
Depending on exactly what you're after, you could also look at Boost.asio and/or LibCurl.

Related

Whats the most basic way to go online in c++?

What is the most basic way to go to a webpage and download its contents? the webpage i wish to get only has text, most of which is in tables.
is there a std library that does it (like urllib in python)?
There's no official C++ network library, no. There are many different APIs available, though. Which is best for you would depend on what platform(s) you were targeting and what framework(s) you might already be using.
That said, cpp-netlib is a platform-neutral API that follows C++ idioms nicely. I've used it and it works.
A large number of tasks that are not covered by the C++ standard library can be done using boost, the collection of peer-reviewed portable libraries, which are used by pretty much every C++ project today. For networking, we use boost.asio.
Their tutorials include HTTP clients: http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/example/http/client/sync_client.cpp and http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/example/http/client/async_client.cpp
However, although this is highly portable and may end up becoming part of the C++ standard library in future, it is a bit too low-level for your task. libCURL is the today's default library for HTTP downloads.

What is the C version of RMI

I have a set of functions in C/C++ that I need to be available to accept calls and return values to C/C++ code in a remote location, similar to RMI on the java platform. With RMI the Java methods are set up through the rmiregistry and remain available in memory to accept requests. I'm looking for similar functionality in C/C++, but i'm a bit confused with all the options that are out there. Is this type of scenario that CORBA was intended for and if so, is this still the best technology to use or are there better options out there. I've read about XML-RPC, CORBA, and a few others but i'm not sure which of these is what i need.
Thanks for your help.
Mike
Is this type of scenario that CORBA was intended for and if so, is this still the best technology to use or are there better options out there.
Yes, this is what CORBA was intended to solve. Whether it's "best" is subjective and argumentative. :) I can say, from my personal experience, I don't miss my short experience with CORBA and would suggest you explore other options.
I've read about XML-RPC, CORBA, and a few others but i'm not sure which of these is what i need.
As you seem to be aware, you're looking for any technology that implements RMI (also frequently called RPC). It's not built-in to C/C++.
On Linux, there is SunRPC. I would also recommend looking at Google protocol buffers, which provide a mechanism for serializing data as well as an interface for defining RPC services. There are several service implementations available, but I don't have experience with the service implementations.
On Unix-like platforms, you're probably looking for Sun RPC (remote procedure calls).
CORBA is also relevant but has a more natural binding to languages with object oriented capability.
There's no built in method for accomplishing this in C or C++. That said there are several libraries that can accomplish this.
If you're on Windows, then the best answer is probably DCOM, which is part of the OS itself. I'm not sure about other platforms.
I shall suggest either CORBA or any webservice library available
CORBA is a reasonable choice for you (though it may be a little bit old technology for now). I have been using CORBA for several years in my previous job.
I should say, learning curve for CORBA is kind of steep, and you need to cater a lot of extra setup, but once it it done correct, it become smooth to use. (The problem is it takes really some time to use it correctly)
Webservice is an de facto industrial standard now, and I believe C++ will have some reasonable implementation and library for that. CORBA cover more features than WS but those feature are seldom used in simple systems.

Accessing a webpage in C++

Is there a good, simple library which allows C++ to load a webpage? I just want to grab the source as text. I'm not using any IDE or significant library, just straight command line.
Tangentially, is there something fundamental I'm missing about programming in C++? I would think any language in common use today would have droves of web-based functionality, being so central to computer usage, but I can find next to no discussion on how to accomplish it. I realise C++ significantly predates the modern internet, so it lacking any core ability in the regard is reasonable, but the fact that relevant libraries seem so sparse is baffling.
Thanks for your help.
Sure, for example libcurl is powerful and popular.
Internet-related libraries for C++ are extremely abundant -- they're just not part of the C++ standard, partly because the current version of that standard is so old, though I'm sure that's not the only reason. But turn to the world of open sources and you'll find more than you can shake a stick at.
libcurl is a popular C library for fetching HTTP and other URLs. There's also cURLpp a C++ binding .
On Windows you have the WinINet and WinHTTP APIs.
I think HTTP is a bit too complex to be part of the C++ Standard Library. The specification would have to take a lot of details into account such as proxy servers and MIME types.

C++ Libraries similar to C#?

I'm coming to C++ from a .Net background. Knowing how to use the Standard C++ Libraries, and all the syntax, I've never ventured further. Now I'm looking learning a bit more, such as what libraries are commonly used? I want to start getting into Threading but have no idea to start. Is there a library (similar to how .net has System.Threading) out there that will make it a bit easier? I'm specifically looking to do Linux based network programming.
For C++, Boost is your everything. Threading and networking are among the things it offers. But there's much more:
Smart pointers
Useful containers not found in the STL, such as fixed-size arrays and hashtables
Closures
Date/time classes
A foreach construct
Min/max functions
Command line option parsing
Regular expressions
As the others have said, Boost is great. It implements the C++ Technical Report 1 in addition to tons of other stuff, including some mind-blowing template metaprogramming tricks.
For other cross-platform features not provided by Boost, I've had very good luck with a library called Poco. I've worked on commercial projects that incorporated its simple HTTP server, for instance, and it treated us quite well.
lots of boost suggestions, but Qt is another good option. It's got great support for threading and networking along with pretty much everything else.
http://qt.nokia.com/products
If you are looking into network programming and are not interested into GUI, I suggest Boost libraries: in particular, Asio.
There's no standard multithreading library, but the boost library includes a platform-independent multithreading abstraction that works very well.

ACE vs Boost vs POCO [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I have been working with the Boost C++ Libraries for quite some time. I absolutely love the Boost Asio C++ library for network programming. However I was introduced to two other libraries: POCO and Adaptive Communication Environment (ACE) framework. I would like to know the good and bad of each.
As rdbound said, Boost has a "near STL" status. So if you don't need another library, stick to Boost. However, I use POCO because it has some advantages for my situation. The good things about POCO IMO:
Better thread library, especially a Active Method implementation. I also like the fact that you can set the thread priority.
More comprehensive network library than boost::asio. However boost::asio is also a very good library.
Includes functionality that is not in Boost, like XML and database interface to name a few.
It is more integrated as one library than Boost.
It has clean, modern and understandable C++ code. I find it far easier to understand than most of the Boost libraries (but I am not a template programming expert :)).
It can be used on a lot of platforms.
Some disadvantages of POCO are:
It has limited documentation. This somewhat offset by the fact that the source is easy to understand.
It has a far smaller community and user base than, say, Boost. So if you put a question on Stack Overflow for example, your chances of getting an answer are less than for Boost
It remains to be seen how well it will be integrated with the new C++ standard. You know for sure that it will not be a problem for Boost.
I never used ACE, so I can't really comment on it. From what I've heard, people find POCO more modern and easier to use than ACE.
Some answers to the comments by Rahul:
I don't know about versatile and advanced. The POCO thread library provides some functionality that is not in Boost: ActiveMethod and Activity, and ThreadPool. IMO POCO threads are also easier to use and understand, but this is a subjective matter.
POCO network library also provides support for higher level protocols like HTTP and SSL (possibly also in boost::asio, but I am not sure?).
Fair enough.
Integrated library has the advantage of having consistent coding, documentation and general "look and feel".
Being cross-platform is an important feature of POCO, this is not an advantage in relation to Boost.
Again, you should probably only consider POCO if it provides some functionality you need and that is not in Boost.
I've used all three so here's my $0.02.
I really want to vote for Doug Schmidt and respect all the work he's done, but to be honest I find ACE mildly buggy and hard to use. I think that library needs a reboot. It's hard to say this, but I'd shy away from ACE for now unless there is a compelling reason to use TAO, or you need a single code base to run C++ on both Unix variants and Windows. TAO is fabulous for a number of difficult problems, but the learning curve is intense, and there's a reason CORBA has a number of critics. I guess just do your homework before making a decision to use either.
If you are coding in C++, boost is in my mind a no-brainer. I use a number of the low level libraries and find them essential. A quick grep of my code reveals shared_ptr, program_options, regex, bind, serialization, foreach, property_tree, filesystem, tokenizer, various iterator extensions, alogrithm, and mem_fn. These are mostly low-level functionality that really ought to be in the compiler. Some boost libraries are very generic; it can be work to get them to do what you want, but it's worthwhile.
Poco is a collection of utility classes that provide functionality for some very concrete common tasks. I find the libraries are well-written and intuitive. I don't have to spend much time studying documentation or writing silly test programs. I'm currently using Logger, XML, Zip, and Net/SMTP. I started using Poco when libxml2 irritated me for the last time. There are other classes I could use but haven't tried, e.g. Data::MySQL (I'm happy with mysql++) and Net::HTTP (I'm happy with libCURL). I'll try out the rest of Poco eventually, but that's not a priority at this point.
Many POCO users report using it alongside Boost, so it is obvious that there are incentives for people in both projects. Boost is a collection of high-quality libraries. But it is not a framework. As for ACE, I have used it in the past and did not like the design. Additionally, its support for ancient non-compliant compilers has shaped the code base in an ugly way.
What really distinguishes POCO is a design that scales and an interface with rich library availability reminiscent of those one gets with Java or C#. At this time, the most acutely lacking thing from POCO is asynchronous IO.
I have used ACE for a very high performance data acquisition application with real time constraints. A single thread handles I/O from over thirty TCP/IC socket connections and a serial port. The code runs on both 32 and 64 bit Linux. A few of the many ACE classes I have used are the ACE_Reactor, ACE_Time_Value, ACE_Svc_Handler, ACE_Message_Queue, ACE_Connector. ACE was a key factor to the success of our project. It does take a significant effort to understand how to use the ACE classes. I have all the books written about ACE. Whenever I have had to extend the functionality our system it typically takes some time to study what to do and then the amount of code required is very small. I have found ACE to very reliable. I also use a little bit of code from Boost. I do not see the same functionality in Boost. I would use either or both libraries.
I recently got a new job and work on a project that uses ACE and TAO. Well, what I can tell is, that ACE and TAO work and fully accomplish their tasks. But the overall organisation and design of the libraries are quite daunting...
For example, the main part of ACE consists of hundreds of classes starting with "ACE_". It seems like they've ignored namespaces for decades.
Additionally, many of ACE's class names don't provide useful information either. Or can you guess what classes like ACE_Dev_Poll_Reactor_Notify or ACE_Proactor_Handle_Timeout_Upcall can be used for?
Additonally, the documentation of ACE is really lacking, so unless you want to learn ACE the hard way (it is really hard without any good documentation..), I would NOT recommend using ACE, unless you really need TAO for CORBA, If you don't need CORBA, go ahead and use some modern libraries..
Boost enjoys a "near STL" status due to the number of people on the C++ standards committee who are also Boost developers. Poco and ACE do not enjoy that benefit, and from my anecdotal experience Boost is more widespread.
However, POCO as a whole is more centered around network-type stuff. I stick to Boost so I can't help you there, but the plus for Boost is its (relatively) widespread use.
The ACE socket libraries are solid. If you are trying to port a standard implementation of sockets you can't go wrong. The ACE code sticks to a rigid development paradigm. The higher level contructs are a little confusing to use. The rigid paradigm causes some anomolies with exception handling. There are or used to be situations where string value pairs being passed into an exception with one of the pair being null causes an exception throw in the exception that will boggle you. The depth of the class layering is tedious when debugging. I have never tried the other libraries so can't make an intelligent comment.
Boost is great, I've only heard good things about POCO (but never used) but I don't like ACE and would avoid it in future. Although you will find fans of ACE you will also find many detractors which you don't tend to get with boost or poco (IME), to me that sends a clear signal that ACE is not the best tool (although it does what it says on the tin).
Out of those I've only ever really used ACE. ACE is a great framework for cross-platform enterprise networking applications. It's extremely versatile and scalable and comes with TAO and JAWS for quick, powerful development of ORB and/or Web based applications.
Getting up to speed with it can be somewhat daunting, but there is a lot of literature on it, and commercial support available.
It's somewhat heavy though, so for smaller-scale apps it may be a bit of an overkill. Reading the summary for POCO it sounds like they're aiming for a system that can be run on embedded systems so I'm assuming it can be used in a much lighter way. I may now give it a whirl :P
I think it is really matter of an opinion, there is hardly a right answer.
In my experience with writing portable Win32/Linux server code (15+ years), I personally find boost/ACE unnecessarily bloated and introduces maintenance hazards (otherwise known as "dll hell") for the little advantage they give.
ACE also seems to be horribly outdated, it is a "c++ library" written by "c programmers" in the 90-s and it really shows in my opinion. It so happens, right now I am re-engineering the project written with Pico, it seems to me it completely follows the ACE idea, but in more contemporary terms, not much better at that.
In any case for high performance, efficient, elegant server communications you might be better off not using any of them.