in reply to Can this be done?

nikita,

As others have pointed out, it's trivial for a cgi (in whatever language) program to interact with another program. Happens all the time in perl where the script either fork/execs, systems, or backticks a program.

That being said there's one part of your question that puzzles me - the user can contitue interacting with the program via the html page ... c++ does not finish after the first output. This is going to be quite difficult due to several reasons:

Even if you get around those limitations with state tricks and apache embedding (mod_perl), web servers tend to be farms so you may have to coordinate across web serves too (or at least ensure the request always goes to only one machine in the farm - hooray for mod_rewrite/mod_proxy).

That being said, I think what you want can be done but it's going to take a lot of planning and a lot of design.

-derby

update: Now that I think of it, this would be kinda neat to set up as a SOAP server. You would wrap the c++ in a SOAP server and then the cgi-script would just be a SOAP client. You may still need to keep state with your cgi-script but you wouldn't need to worry about the lifetime of the c++ program (at least not in your web server/cgi world).

Replies are listed 'Best First'.
Re: Re: Can this be done?
by erikharrison (Deacon) on Mar 11, 2002 at 20:16 UTC

    Cookies, of course, can allow you to add state management to a HTTP transaction. This might be a way to handle the page to page state maintainance.

    However, cookies can be dangerous (or irritating) if poorly handled and your CGI program is non trivial. http://web.stonehenge.com/merlyn/WebTechniques/col61.html is merlyn's fine, fine article on how to use cookies well. Even if cookies aren't the appropriate solution this time around, if you are writing alot of CGI scripts you ought to read it.

    Cheers,
    Erik