?
Solved

Send data between console apps

Posted on 2005-04-16
4
Medium Priority
?
213 Views
Last Modified: 2010-04-15
I've got two instances of the same console application.

The first one creates some data (char * data) of some length. This data should be sent to the second program that'll process the data.

Thus:

    CONSOLE 1          header|length|data       CONSOLE 2
    char* data;         ----------------------->    received_data = malloc(length*sizeof(char));
    int length;

I've tried using _pipe, but this seems not to work.

Note that the CONSOLE 2 will stay in wait mode until it receives a message with the correct header.

I'd like a solution that's a simple as possible, if possible without needing additional non standard libraries. Saving the data to the HDD is not an option.

All this should work under Linux, as well as under Windows (or at least, there should be an alternative for both).

Thanks in advance!
Evarest
0
Comment
Question by:Evarest
3 Comments
 
LVL 22

Accepted Solution

by:
grg99 earned 260 total points
ID: 13799467
I'd use a TCP connection.  

On a similar project, after messing around with pipes for days, and finding all kinds of glitches, I switched to a TCP connection, which worked first time, and works identically on all cptrs.

0
 
LVL 45

Assisted Solution

by:sunnycoder
sunnycoder earned 240 total points
ID: 13799776
I would second greg's recommendation ... use sockets ... They are far more easier to deal, more portable, etc. etc. than any other IPC mechanism

However, for the kind of communication you mentioned, even pipes should suffice ... you do not necessarily have to implement them on your own ... you can start up your application by adding pipe from the shell while launching them

my_app_1 | my_app_2

will do what you are looking for and works on windows and Linux
0
 
LVL 4

Author Comment

by:Evarest
ID: 13957869
I'm sorry i left this so long, but i had quite a busy month...

In the end, i used neither solution, as i only had to implement a skeleton app... However, i'll keep in mind this discussion for future use.

Thanks again!
Evarest
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question