Reputation: 1394
I am writing a C++ HTTP server. But because developing in C++ is slower as for example in PHP I want to also support FastCGI applications (PHP via FastCGI, Python via FastCGI, etc.). So I want to use something similar to mod_fcgi (for Apache). Does someone know a good C++ FastCGI library (not for applications but for the webserver) ? I use the Poco library to write the webserver.
Another solution could be to use an PHP interpreter directly in my C++ server. Does anybody know some examples for this?
All solutions must have performance in mind.
Upvotes: 1
Views: 2022
Reputation: 1394
I could not find a FastCGI client, so I wrote it myself. It was a lot of work, but i succeeded :) It is a lot faster then plain old CGI (duh!).
Upvotes: 0
Reputation: 11220
I've been looking at this topic yesterday. As you may know, fastcgi is built over tcp or unix socket waiting for a connection with a specific protocol.
The scheme of a request is the following: A client connects to the webserver, which connects to the fastcgi application.
Depending on the implementation (the specs says that the webserver gives a file descriptor connected to the webclient (the accept()
sockfd) to the fastcgi applciation. I have not seen such a behaviour with nginx.
How can you experiment?
php-cgi
on localhost port 9000 (./sapi/cgi/php-cgi -b 127.0.0.1:9000
)nc -l 9000
)I found fcgi specification which is very usefull if you want to write your own library. I've not been (yet) able to find C/C++ code for a client to fcgi, but it can easily be found for perl.
Upvotes: 1
Reputation: 18210
If you are writing a CMS system in C++, you should checkout CppCMS web framework in C++, its seems to be very fast.
If you are wanting to do it more from scratch and write the HTTP server, boost has some examples on how to setup an HTTP server here.
Now if you want to use CGI which is the slowest option, there is a GNU Cdicc library for handling CGI.
Upvotes: 1