简体   繁体   中英

what is pros and cons of using Socket for IPC between java and c++?

I recently forced to find an IPC protocol that is best for communicate between java and c++.

I searched the SO for finding best protocol for this, I found socket is the best approach for this, in SO. But I couldn't find any thing about its cons or pros of sockets. So I want to know pros of this protocol and also I want to know pros of other protocol vs socket to choose best protocol for my application.

It is very likely that my two applications running on a same machine.

I should first select my protocol then I can decide run it on which system configuration.我应该首先 select 我的协议然后我可以决定在哪个系统配置上运行它。

The best IPC method really depends on what type of communication you have: Message passing, ensuring mutual exclusive execution, sharing data are various IPC, but sockets isn't the solution for all 3.

Think about, or provide information what form the information has you want to pass between the applications. Perhaps you find a typical scenario (like producer-consumer problem).

If you have a message-passing problem, comparable in principle to oldschool TCP services, sockets are a good idea because they are well-tested and easy to debug; They provide full decoupling, yet running locally doesn't have drawbacks compared to pipes because the kernel can do the blocking of one application (sender or receiver) efficiently.

Sockets can be UDP, TCP or Unix sockets. In any case you don't need a.network card for local IPC with sockets.

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