views:

72

answers:

1

I worked on a Unix app where two applicants ran and talked to each other using the command-line, i.e each had a loop something like (treat this as pseudo code):

bool stop=false;
do
{
  stringstring cmdBuffer;
  cin >> cmdBuffer
  string ret = processCommand(cmdBuffer);
  if(ret.length()==0)
    stop=true;
  else
    cout << ret;
}
while(!stop);

Is there any reason two Windows apps can't do the same? Would they have to be running on the same 'command prompt' or be console apps, or does the notion of command-lines go beyond being able to see a command prompt in front of me?

For reference, in my case one app would be running the other, they're not two separate apps run up independently.

+1  A: 

I'd say redirect the input and output handles(SetStdHandle), but using a named pipe is safer and more secure, plus you can use sync functions on it.

you can also use a global mutex/event or Mapped memory instead, as both are globally named and easy to get/set and read/write to.

Necrolis