• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 218
  • Last Modified:

Send data between console apps

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.


    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!
2 Solutions
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.

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
EvarestAuthor Commented:
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!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now