Overview
Features
Download
Documentation
Community
Add-Ons & Services

Poco::Pipe usage?

A general discussion forum.

Poco::Pipe usage?

Postby directx11 » 07 Dec 2008, 13:30

Hi, i'm new user of the poco library. On the start i have problem with usage of Process and Pipes objects - i cannot find any working sample of that. I need even simplest sample how to run it in proper way. I'm fresh in inerprocess programming, so maybe here is the problem. But nice small example would be appreciated.

// master program

int _tmain(int argc, _TCHAR* argv[])
{
Poco::Pipe out_pipe_1;
Poco::Pipe in_pipe_1;
Poco::Process::Args args_1;
Poco::ProcessHandle proc_handle_1( Poco::Process::launch( "test.exe", args_1, &in_pipe_1, &out_pipe, 0 ) );
unsigned char buff[] = { 'a', 'b', 'c', 'd', 'e' };

in_pipe_1.writeBytes( (void*) buff, 5 );
proc_handle_1.wait();
return 0;
}

// process to run

int _tmain(int argc, _TCHAR* argv[])
{
unsigned char buffer[5];
Poco::Pipe pipe;

memset( buffer, 0, 5 );
// and now what?
i've try to use readBytes() method of pipe, but probably nothig is passed to this process, it hangs and nothing happens.
return 0;
}

Maybe here is some other philosophy, how it should be handled? Any tip is welcome.
directx11
 
Posts: 3
Joined: 05 Dec 2008, 16:11

Re: Poco::Pipe usage?

Postby guenter » 07 Dec 2008, 14:09

There is a sample in the Foundation testsuite. See Foundation/testsuite/src/ProcessTest.cpp (testLaunchRedirectIn() and testLaunchRedirectOut()).
guenter
 
Posts: 1112
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Poco::Pipe usage?

Postby directx11 » 07 Dec 2008, 19:29

Thanks, now it works (:mrgreen:)
directx11
 
Posts: 3
Joined: 05 Dec 2008, 16:11

Re: Poco::Pipe usage?

Postby directx11 » 09 Dec 2008, 12:36

To not make a mess, second question of beginer. Still have problem with the process launched by poco. Let's assume, that i want to have two process, both have "while()" statement inside. I want that two procesess could start and continuosly exchange data in loop (like two separate apps with windows). But when both procesess have while() loop, one of them hangs and don't want to process messages. In this case process object from poco is right way? See example below:

// proc 1
main()
{
// launch process using poco
..

while( 1 )
{
// send something using pipe
}
}

// proc 2
main()
{
while( 1 )
{
// receive something using pipe
}
}

But proc 2 doesn't work. Is it not possibe to run two processess in this way? Maybe this should be done in completly another way?
directx11
 
Posts: 3
Joined: 05 Dec 2008, 16:11


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron