Remote C++ Program Start up

Pages: 12
I was wondering if it was possible to have a C++ program on a different hosted server, and when someone connects to the C++ program and selects an option, it will open up a web page for them. Kind of like clicking a link and opening up a new web page but they have to connect to the C++ program first. Is this possible or not?
I believe a C++ CGI would serve your needs. But CGI has been obsoleted by today Web standards so I would think having a Web-enabled language (PHP, Perl, Python etc) to wrap your C++ program would be a better choice.
So theres no command like ShellExecute but to have the ShellExecute open a program on their computer instead of on the host?
I am not saying there is no command but I am assuming you want some Web behavoir in your requirements. For cgi-bin executable, it is usually something similar to http://www.yourdomain.com/cgi-bin/testcpp where testcpp is the C++ compiled binary residing in the Web server cgi-bin directory.

The testcpp would most likely print HTTP header, HTML tag code etc in your case appear a "menu" on the Web browser. The menu would have hyperlinks for user to click.

In fact for CGI binaries which can be Perl, C program etc etc, they typically read from stdin and write to stdout. However when writing out to stdout they need to conform to HTTP protocol which mandates the HTTP header.

In Google search, type "c++ cgi example" to see some examples on how it works.
So using this would it be possible to just redirect someone to a webpage?
It seems like you have to make your own webpage in cgi so would I have to make a webpage in cgi just for the sole purpose of redirecting to another webpage?
I am making an assumption the client connect to your C++ program using the browser (FF or IE). If you do not want that then obviously what I propose above does not apply.

Then the question become what do you have in mind for the very first client initial connect to your C++ program ?

It connects with telnet, I need to have it open their browser if they type browser and press enter
Nah, there's no way to do that directly. At the very least, the client would need to have some program running that the server can connect and send commands to. Either that, or a custom telnet client that reacts to specific replies from the server.
Couldn't the browser command do shellexecute for the client instead of the server somehow?
The problem is the "somehow". You can't directly start processes on a different computer. You need some mediator to bridge the two computers.
The mediator is the telnet client that's connected to the host isn't it? Can't my host tell the telnet client connected to open a program?
Can't my host tell the telnet client connected to open a program?
No. The Telnet client is merely acting as a communications bridge. You want both to communicate, and for the client to act based on the contents of the communication. That's simply not in the Telnet protocol. If you want that kind of behavior, the client would have to be customized.
Ah, Ok I understand now, thanks for everyone's help.
To allow a host to tell a client to run a program on a client machine can be very dangerous, so most open Web protocols would disallow this kind of thing. Remember, under the standard convention, it is the client telling the server to run something/provide a service, and not the other way around. Think about it in terms of web browsers: would you use a web browser which, when you connect to a certain URL, to allow that web server to run a program on your machine?

That being said, if you have total control over the client and the server and the underlying protocol, you can do whatever you want.

Does it have to be a C++ program on the server end?
What are, specifically, your requirements for the client and server, in terms of services?
In other words, what, exactly, are you trying to do?

If you are just trying to, say, verify the identity of someone with a log-in and password, the simplest solution is a web browser as a client, and a web server serving https on the other end. My personal leaning is to make things as simple as possible, but I have no idea what your requirements really are.

Last edited on
Yes it has to be a C++ program at the server end. Imagine it like clicking a link in the browser. A new web page opens up, I wanted this to happen except using a C++ program.
Imagine it like clicking a link in the browser. A new web page opens up
The difference is that HTTP is designed for this sort of thing.
Do you have control over what client is used?

Is it a browser or already existing client or is it a hand-written client?
Last edited on
The client is world of warcraft.
Then I suppose you should investigate the WoW add-ons API.

Look for these functions in the WoW add-ons API:
1. Ability to open a socket (so you can talk to a C++ server that you write)
2. Ability to open a web page or to ask the OS to open a webpage

If those two pieces are available, your algorithm in your add-on could be:
1. Attempt to open a socket to the server
2. Query the server for the page to open
3. Open the page
Last edited on
Pages: 12