Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Interprocess communication using pipe

Hi guys

I am having problems creating a "process race" application.
The following is what I have come up with so far:

A child process

#include
#include
using namespace std;

int main (int argc, TCHAR *argv[])
{
for(long i=0;i<1000000000;i=i+10000){
cout << i;
}
return 0;
}

Main program (excerpt)

while (true)
{
for(int i=0;i<antalProcesser;i++)
{
ReadFile(hPipeLasning[i],&t,sizeof(long),&dw,NULL);
FlushFileBuffers(hPipeLasning[i]);
*&processPosition[i] = t;
}
}

where hPipeLasning is the handle to read from the pipe. Why does this solution not work, I get really weird numbers. My basic idea was that I would use cout to send numbers (long) through the pipe. In the main program I would read the number from the pipe and update a posistion variable (processPosition[i]). What am I doing wrong? Do I have to do something special in the child program?

I would appreciate some help.

Thx
David

Comments

Sign In or Register to comment.