Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello all,
I am trying to run a 'simple' C++ program on a server. Before everyone says use PHP, Javascript... Its not that simple I am using libraries in C++ that are not available to PHP and Javascript.
So for example if I had a simple C++ program that created a file containing "Hello World!". Can someone explain a way in which I could run this program on a sever essentially putting this file on the server.

Hope that makes some sense.
Posted
Comments
Sergey Alexandrovich Kryukov 23-Jan-13 12:28pm    
You can, but the server will hardly appreciate your greeting? Why?
And now, the rest of the answer totally depends on what server-side technology you use. Before you tell us what it is, there is nothing else to discuss.
—SA

PHP, JavaScript etc... run using the CGI[^] method.

Any executable can be run this way and it simply needs to return a valid HTML string.

But every web server has optimizations built in to speed up the execution of a url. That's likely where Sergey is coming from in his comment.

Imagine if you have a CGI process that takes 25 seconds to initialize, calculate the answer and then return. Then you start getting 100 hits a minute on that process... Your server performance is going to suffer tremendously.

To solve this problem, web servers will usually support DLLs as an extension for CGI scripts. You associate a file extension with the DLL, and that file and HTTP requests will be passed to a call in the DLL for processing.

Using this method, allows for pre-caching of the files, and pre-Loading DLLs. This saves quite a bit of time in handling requests.

To provide specific recommendations, we need to know what server you're using.
 
Share this answer
 
Comments
Espen Harlinn 23-Jan-13 17:47pm    
Well answered :-D
Jibesh 23-Jan-13 17:56pm    
my 5
Use CGI, have a look at:
CGI[^]

Enabling FastCGI on IIS 7[^]

You could also work your way from one of the expample
http servers provided with the Boost C++ library[^]

Best regards
Espen Harlinn
 
Share this answer
 
v2
Quote:
Before everyone says use PHP, Javascript... Its not that simple I am using libraries in C++ that are not available to PHP and Javascript

However you may use PHP system() function to call your executable.
 
Share this answer
 
Comments
fjdiewornncalwe 23-Jan-13 16:51pm    
My 5
Espen Harlinn 23-Jan-13 17:28pm    
That should work :-D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900