For a minimal amount of work, it's almost like you'd want a CGI-esque-
interface to your C++ program, so all stdin/stdout is piped thru HTTP.
A Web CGI environment takes:
1) a web server that speaks HTTP requests and responses
2) some executable program
3) and pipes 2)'s stdin and stdout to http request and http response.
You might be able to simulate some level of interactivity by writing
JavaScript that interacts with a form textarea for input (Tin) and
another form textarea for server output (Tout).
A "POST" XmlHttpRequest could send a snapshot of what's in Tin to your
program via CGI. Your program would then send its response
encapsulated in an HTTP response. The script could snatch that and
insert it in Tout, or even into Tin to simulate chained input/output
you described.
In these days of higher-level web frameworks, this would be a pretty
cool way of going back old-school to the original CGI days, 1995-
style :)
You might look at
http://httpd.apache.org/ on some linux box, and read-
up on "configuring cgi scripts".
You would likely need to "amend" your program to send some HTTP
headers before everything it sends back to stdout, because a browser
only speaks HTTP, and i believe a basic CGI setup just blindly pipes
the stdin/stout between the browser and the server.
As a result, your program would likely need a little bit of string
parsing to get past various HTTP Headers being sent in a "POST"
XmlHttpRequest.
I bet there are C++ CGI libraries that abstract this tedium for you :)
http://www.google.com/search?q=c%2B%2B+cgi+libraries
-chris
On May 31, 2:29 pm, partialprogress...@gmail.com wrote:
I have a c++ program that runs with interactive text input and output
with stdin and stdout. I want to change it to run from a server, with
the interaction via web browser. It is not practical to port the
whole program to a web scripting language.
The program requires several iterations of input and output without
losing its state, and it is resource intensive, so it can't just be a
function call that passes in the input and gets the output on the
program end.
I know virtually nothing about web programming. Can this problem be
solved with javascript? If so, what do I need to do to my C++
program, and what kind of script do I need? If not, where could I
ask?
Thanks.