Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
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 23-Jan-13 5:46am
Comments
Sergey Alexandrovich Kryukov at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Marcus Kramer at 23-Jan-13 16:51pm
   
My 5
Espen Harlinn at 23-Jan-13 17:28pm
   
That should work :-D
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  
Comments
Espen Harlinn at 23-Jan-13 17:47pm
   
Well answered :-D
jibesh at 23-Jan-13 17:56pm
   
my 5

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 397
1 OriginalGriff 350
2 thatraja 205
3 Emre Ataseven 165
4 Shai Vashdi 150
0 Sergey Alexandrovich Kryukov 8,894
1 OriginalGriff 5,200
2 Peter Leow 3,955
3 Maciej Los 3,535
4 Abhinav S 3,208


Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 23 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid