The Unknown
The Unknown

Reputation: 19684

Giving C++ Application a HTTP Web Server Functionality

I have a C++ app and looking for a library that would make it a HTTP Server that's able to serve static files as well as perform very simple tasks. The only constraint is that it must be Cross-platform.

What are my options.

Clarify: I need a web interface for my application. This application is a background program that does other tasks. I want to provide a way so you can access http://localhost:9999/performtask or http://localhost:9999/viewstatus

clarification2: something like this http://www.gnu.org/software/libmicrohttpd/

Upvotes: 2

Views: 7109

Answers (8)

Bklyn
Bklyn

Reputation: 2568

In a question which has since been deleted, I asked:

I'm looking for a well-written, flexible library written in C or C++ (I'm writing my apps in C++) that can be used to embed an relatively simple HTTP server into my applications. Ultimately I will use this for application monitoring and control.

There are a number of great client-side libraries (e.g. libwww, neon, curl) but I'm struggling to find a good solution for the server-side. I'm sure other folks have done this before, so I'd love to hear what folks have done and what has worked and what hasn't.

I ended up choosing Mongoose.

Upvotes: 5

d3bt3ch
d3bt3ch

Reputation: 409

Just a thought !

Why don't you convert your c++ application code to a native/extension module for any of the following http servers.

  • Apache Webserver
  • IIS 7.0 native module
  • Nginx
  • LightHttpd

All the above servers except IIS are cross platform.

Maybe building an extension module would yield a better output and the above server are very scalable too.

Upvotes: 1

James Brock
James Brock

Reputation: 3426

I accomplished the same thing you want to accomplish by using the HTTP Server example for boost::asio.

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

This was a perfect solution for me, because my project was already dependent on boost::thread and boost::asio, so the HTTP Server example code fit into my application and I could easily have complete control over its threading behavior. I just copied HTTP Server example files into my project and customized the request-response logic.

Upvotes: 1

user52875
user52875

Reputation: 3058

The Wt library does exactly this. Recommended, especially if your user interface gets more complex.

Upvotes: 1

Walt C.
Walt C.

Reputation: 51

Take a look at Snorkel it is a light weight fast cross-platform embedded/application server SDK that allows you to quickly add web interfaces to any C/C++ application. Its free and can be found at http://sites.google.com/site/snorkelembedded. Its faster than mongoose.

Upvotes: 0

jdkoftinoff
jdkoftinoff

Reputation: 2421

I am partial to the poco library as a starting point.

Upvotes: 0

Ian
Ian

Reputation:

Qt framework have buildin webkit. have a lookinto that.

Upvotes: -1

digital me
digital me

Reputation:

Java would be a better choice for a cross-platform solution plus it has good web services apis. Take a look at Netbeans it is a good way to get started.

Upvotes: -2

Related Questions