3

My requirement is to IPC between a C client and Java server on Windows using JSON strings.

Just realized that I can't use named pipe ("\.\pipe\filename") in Windows from java. I'm not too keen on using any network based architecture, because its gonna get more complicated to ensure the security and speed.

Kindly suggest any shared memory/fast solution you happen to know?

Thanks in Advance :)

  • Have you considered creating a native class to manage the IPC for you? If you prefer named pipes, this should be easy enough to do. – mah Jun 29 '12 at 10:54
  • If you want speed I am surprised you are using JSon. This can slow you down more than using Sockets over loopback. – Peter Lawrey Jun 29 '12 at 10:57
  • 1
    Your question is based on an incorrect premise. Nothing about using sockets makes ensuring security and speed more complicated. Sockets are the right solution, most likely. – David Schwartz Jun 29 '12 at 11:00
  • 1
    Why can't you use named pipes? Are you trying to connect on same machine or different machine, which mode fails for pipes? – Ajay Jun 29 '12 at 11:05
  • Ajay,it is on the same machine. Named pipes in Windows live in a special filesystem which can be used only by Win32 API, which makes it difficult for me as I use java at one end. Please Correct me if I'm wrong. – Jose Praveen Jul 04 '12 at 12:02
  • Mah, Peter, David, thanks for the help. Yeah, I concluded that protected sockets are the best solution and am already implementing it. Cheers :) – Jose Praveen Jul 04 '12 at 12:06
  • as @DavidSchwartz said **socket** is the best method for implementing IPC for such situation – fadedreamz Aug 15 '12 at 23:34

2 Answers2

0

You can use named pipes on Windows; the answers to this question and this question give different solutions to that.

In addition to those, by using llvm (clang, in your case) followed by the LLJVM Translator, you can compile code from hundreds of programming languages to LLVM bytecode, and then translate that to JVM bytecode, at which point your existing Java code can call functions from your (compiled and translated) code.

Last but certainly not least, in order to avoid doing work that you might not need to do, you should focus on solving your problems using clear, maintainable code, and leave optimisation until you're certain that it needs to be done. At that point, your profiler becomes your friend for measuring the bottleneck and verifying the optimisations you perform.

autistic
  • 1
  • 3
  • 35
  • 80
0

You can use UDP or TCP for IPC.

It is also quite portable solution, if you later move your programs to an other OS.

With TCP, it is quite easy to scale the system: ie: running programs in different hosts. Because of unreliable nature of UDP, it may be little bit harder to use it over unreliable network.

SKi
  • 8,007
  • 2
  • 26
  • 57