简体   繁体   中英

Designing a cross platform communication interface

I have a C# program running on a local system that needs to be able to do two things.

  1. Asynchronously spin off remote jobs on remote systems running Windows, Linux, or Android.
  2. Provide a way for those systems to send back the output(StdOut/StdErr) of those jobs back to the local system.

Previously I have used WCF when communicating with a remote windows system. I created a WCF server on the remote windows system and then my local machine can send commands and messages via that WCF channel. Things get more complicated when I try to do the same thing with Linux and Android.

I figure I could setup a local WCF service using REST, that way all 3 platforms can send messages to it using whatever convenient language (Most likely c++) via JSON REST. But what then is the best way to accomplish requirement #1?

Should I bother creating a REST server in C++ that runs on Linux and Android? Can WCF even consume a C++ REST server that isn't written in .Net? Would I be better off doing something simple with just TCP sockets?

Security is not an issue since this is used on a secure private network. I'm just looking for the easiest way to run remote commands/processes and receive response messages from those remote systems.

I use ZMQ and JSON for exactly this purpose: creating a custom private network topology that communicates using JSON messages over TCP (via ZMQ). Of course you could use any serialization format (I list some alternatives below).

I can't give you a definitive "this is what you should do" answer, because the question is fairly open-ended.

  • ZMQ: http://www.zeromq.org/
    • Really nice cross-platform abstracted socket library
    • Can use various transport protocols, including TCP
    • Sends messages as just plain byte arrays, leaving choice of serialization format up to you
  • Some serialization formats (in order of my personal preference):

This can really depend on your infrastructure and services you are using. If you are in the Amazon Web Services world you could use a Simple Queue Service (SQS) to receive messages. The remote systems could then poll the queue and run the jobs based on the messages pulled off the SQS queue.

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