简体   繁体   English

使用posix ipc消息队列通信Java应用程序和C ++进程

[英]communicating Java application and C++ process using posix ipc message queues

It's quite difficult for me to explain what I need to implement, so I really hope I am able to do it. 我很难解释我需要实现什么,所以我真的希望我能够做到。

I have a C process which uses an ipc message queue to send and receive data. 我有一个C进程,它使用ipc消息队列发送和接收数据。 I also have a Java application which needs to send and received messages to/from that C process, so it needs access to that queue. 我也有一个Java应用程序,它需要向该C进程发送消息和从该C进程接收消息,因此它需要访问该队列。

I've been searching for a way to do this and I think JNA (java natice access) could be a solution. 我一直在寻找一种做到这一点的方法,我认为JNA(java natice访问)可能是一种解决方案。 The problem is that, apparently, I need a DLL so I can map and use the methods I need (msgget, msgsnd,msgrcv,msgctl), but I don't know which DLL I should load. 问题是,显然,我需要一个DLL,以便可以映射和使用所需的方法(msgget,msgsnd,msgrcv,msgctl),但是我不知道应该加载哪个DLL。 I'm quite new at this so I'm feeling lost. 我对此很陌生,所以我感到迷茫。

Is there another way to get these two applications to communicate using message queues? 有没有其他方法可以使这两个应用程序使用消息队列进行通信? Or is JNA a good solution and I only need to find the correct DLL to load? 还是JNA是一个好的解决方案,我只需要找到正确的DLL即可加载?

Thanks in advance. 提前致谢。

If that is an option, you could change the C process to use a different way of communication. 如果可以的话,您可以更改C进程以使用其他通信方式。 In my experiences Sockets are the least troublesome way of communicating between c and java programs/processes. 以我的经验,套接字是在c与Java程序/进程之间进行通信的最简单的方法。

The use of JNA is perfectly legal, but somehow tricky. JNA的使用是完全合法的,但是有些棘手。

This post " Java POSIX IPC " may have some clues as to how to do that in Java or using Java Libraries. 这篇文章“ Java POSIX IPC ”可能具有一些有关如何在Java或使用Java库中进行操作的线索。

If you can find depend.exe (I know VS 2005 has it), it can show you the functions each dll exports. 如果您可以找到depend.exe(我知道VS 2005拥有它),它可以向您显示每个dll导出的功能。 Run it on your c program to see where the functions are coming from, if they are real you can use JNA. 在您的c程序上运行它以查看功能的来源,如果它们是真实的,则可以使用JNA。 The functions might actually be just wrappers and if so you need to use JNI 这些功能实际上可能只是包装器,如果需要,则需要使用JNI

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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