interaction with server-side c++ program

P

partialprogressive

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.
 
N

noagbodjivictor

Can this problem be solved with javascript?
No.

But.

You can still use C++ as a server side language if you want. Some
people use perl, others PHP, ruby, or even python. Everything depends
on the configuration of your webserver. Nothing to do with Javascript.
 
E

Evertjan.

wrote on 01 jun 2007 in comp.lang.javascript:
No.

But.

You can still use C++ as a server side language if you want. Some
people use perl, others PHP, ruby, or even python. Everything depends
on the configuration of your webserver.
Nothing to do with Javascript.

Nothing to do with clientside Javascript.

Many use j[ava]script as a serverside language.
 
C

ChrisHolland@InternetBrands

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+++cgi+libraries

-chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top