473,387 Members | 1,556 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

interaction with server-side c++ program

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.

May 31 '07 #1
3 2979
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.

May 31 '07 #2
wrote on 01 jun 2007 in comp.lang.javascript:
>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.
Nothing to do with clientside Javascript.

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

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 1 '07 #3
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.

Jun 1 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alex Cicco | last post by:
Hi, I am new to SQL. Please bear with me and allow me to ask a dumb question. I am debugging a stored procedure (written in Trans-SQL), and I found that the SQL analyzer that I use doesn't...
8
by: Jasper | last post by:
I have a noob problem that is fairly expansive. Let me preface it by saying that I'm a beginning programmer and am using the game I'm writing as a learn-as-I-go tool. I'm trying to make a...
7
by: rdh | last post by:
Hi all, I am in process of developing a Server in C++ supporting multiple protocols. The server will be exposing various functionalities, and the clients can communicate over any of the...
3
by: Aaron Queenan | last post by:
I have a form which performs some asynchronous code. I want to display a wait cursor when it starts, and hide the wait cursor when it has completed. This part works fairly well, using: ...
2
by: David Hearn | last post by:
I have a webform that I am creating. I need for the user to be able to pass it the path and name of a file on his/her local machine without any interaction. I don't want to have to use the file...
2
by: Alberto | last post by:
How do you write the interaction diagram's messages in c#? like calling a method in the object class? like an event? Thank you
3
by: Angus | last post by:
I am designing an FTP server and with FTP commands are dispatched on one port and the actual data transmission on another. So I thought I would have a CFTPControl class for handlng the commands...
0
Dököll
by: Dököll | last post by:
ASP.NET and SQL Server 2005 Database interaction includes: Language: ASP.NET Connectivity: SQL Server 2005 Foreword: This database connectivity is nothing of genius, it is a simple...
0
by: =?Utf-8?B?RmlsaXBwbw==?= | last post by:
The idea is to have a SERVICE that receives a request to print a PDF file. What is the recommended way to print a PDF on the server, where there is NO user interaction, NO dialogs ? Thanks, FP
2
by: =?Utf-8?B?RmlsaXBwbw==?= | last post by:
The idea is to have a SERVICE that receives a request to print an HTML string (could be saved as file if needed). What is the recommended way to print an HTML string on the server, where there...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.