Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5957665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:26:01+00:00 2026-05-22T18:26:01+00:00

What is the best way to implement C++/Java IPC for the following situation? (Someone

  • 0

What is the best way to implement C++/Java IPC for the following situation?

(Someone recently asked a similar question, but my requirements are more specific)

  1. I have two programs — one written in C++, the other in Java — that need to communicate with each other. Both are running on the same machine.

  2. The programs send messages to each other. Messages are typically short (less than a few hundred bytes), but could potentially be 100KB or more in size.

  3. Messages do not need to be acknowledged (i.e., not a request/response model like HTTP). For example, the C++ program sends a message to the Java program, and the Java program may reply by sending a message to the C++ program at a later time — and vice versa.

  4. An ideal solution would have a) very low latency, b) no security hassles (user does not have to authorize ports to be opened etc.) and c) will be platform-agnostic.

My first thought was using sockets — each program would act as a server to the other. Sockets have more overhead than other forms of IPC, and I don’t know how the server would inform the client of the port number if I let the system auto-assign port numbers. I’ve also considered named pipes, but they are not supported (at least not consistently) across different platforms. JNI looks like an option, but can it cross process boundaries?

Any suggestions?

Thanks!

FOLLOW-UP QUESTIONS

  1. If I go with sockets, would I need to open two sockets to allow for asynchronous communication as described above?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:26:02+00:00Added an answer on May 22, 2026 at 6:26 pm

    I’d suggest you to use TCP sockets.

    The actual overhead of TCP sockets, as of my experience, is very very low compared to the other tasks’ workload of the applications, at least the ones I use to develop. I mean, sometimes even if sockets’ latency is twice as the latency of other IPC mechanisms, in the overall workflow they have very little impact. And it saves you the hassle of making IPC between a Java application and a C++ one, that will eventually require you to use a specific Java library that uses JNI, with the overhead of JNI and the one of the library itself.

    I’ve actually measured, in my Java applications, that Garbage Collector impact is far more important than the latency caused by “loopback” TCP sockets.

    Moreover, TCP sockets are more scalable (and portable!) than traditional IPC. What if in the future you’ll have to run the client and the server on different machines? In the ‘TCP sockets’ scenario, you’ll have to do a 5-minute hack, in the ‘traditional IPC’ scenario, you’ll have to rewrite the whole IPC stuff.

    However, what is the general workflow of your application?

    Even if the acknowledgement is not required, I’d suggest to use TCP (and not UDP) to avoid unsorted delivery (which leads to pain in the ass when it comes to rearrange the stuff you received – some of your messages are 100KB and this doesn’t fit in a UDP packet).

    In reply to your last question, for the server to inform the client about the port, you can just make the server launch the client with a specific ‘port’ command line parameter, or make the server save a small file under /tmp (or another temporary directory) with the port number written inside.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've read that question & answers: What is the best way to implement constants
Which is the best way to implement a sparse vector in Java? Of course
What would be the best way to implement a most-recently-used cache of objects? Here
What is the best way to implement, from a web page a download action
What is the best way to implement mutliple Default Buttons on a ASP.NET Webform?
What's the best way to implement the enum idiom in Ruby? I'm looking for
What is the best way to implement the page view counter like the ones
What's the best way to implement user controls that require AJAX callbacks? I want
What's the best way to implement a classic curry function in actionscript with a
Whats the best way to implement rollover 'buttons' like Stackoverflow has for 'Questions', 'Tags',

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.