简体   繁体   中英

Embedded C: Different processes sending/receiving data to same input/output

So here is what I'm trying to accomplish it:

处理通讯图

  1. Telnet Client sends a command to Telnet Server (Process 1); - DONE

  2. Process 1 finds which following Process (2, 3, 4 etc) will execute that command and calls that process - DONE

  3. The Telnet Client now needs to see the output of those other processes (say, Process 2) that is executing the command. Process 2 might also need some extra input from the Telnet Client. These are the outer arrows in red.

  4. Process 2 will tell Process 1 once it is done.

My biggest (and maybe only) question is about step 3. How can that be achieved in an efficient way? Is it just a matter of piping stdin of Process 1 to stdin of Process 2, and then stdout of Process 2 to stdout of Process 1?

Not that this question has anything to do with embedded, but the "proper" way to do it would be to have the telnet server act as an intermediary for all communication between the client and the subprocesses 2...n.

I'd be highly suspicious of claims that making a pipe between the client and process 2...n to handle the communication from the client to the subprocess would be more "efficient", unless you're measuring efficiency in latency (ie you're working on something where the shortest time possible is desired...like high frequency stock trading).

And it's a bit more than just piping stdin/stdout. The server needs to mirror the stdin/out (and probably stderr) to the telnet's socket programmatically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM