用于进程间通信的 UDP

发布于 2024-10-15 06:50:51 字数 193 浏览 12 评论 0原文

我必须在同一系统上运行的 java/c++/python 进程之间实现 IPC 机制(发送短信)。一种实现方法是使用 TCP 协议的套接字。这需要保持连接和其他相关活动。 相反,我正在考虑使用不需要连接并且可以发送消息的 UDP 协议。 我的问题是,同一台机器上的 UDP(对于 IPC)是否仍然具有相同的缺点,它适用于跨机器通信(例如不可靠的数据包传输、无序数据包)。

I have to implement IPC mechanism (Sending short messages) between java/c++/python process running on the same system. One way to implement is using socket using TCP protocol. This requires maintain connection and other associated activities.
Instead I am thinking of using UDP protocol which does not requires connection and I can send messages.
My question is , does UDP on same machine ( for IPC ) still has same disadvantage has it is applicable when communicating across machines ( like un reliable packet delivery, out of order packet.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

°如果伤别离去 2024-10-22 06:50:51

是的,还是无法实现。对于本地通信,尝试使用命名管道或共享内存

编辑:

不知道您的应用程序的要求,您是否考虑过类似 MPI(尽管 Java 没有得到很好的支持...)或 Thrift 之类的东西? ( http://thrift.apache.org/ )

Yes, is still unrealiable. For local communication try to use named pipes or shared memory

Edit:

Don't know the requirements of your applications, did you considered something like MPI (altough Java is not well supported...) or, Thrift? ( http://thrift.apache.org/ )

不弃不离 2024-10-22 06:50:51

本地 UDP 仍然不可靠,但主要优点是 UDP 多播。您可以拥有一个数据发布者和多个数据订阅者。内核的工作是将数据报的副本传递给每个订阅者。

另一方面,Unix 本地数据报套接字需要可靠,但不支持多播。

Local UDP is still unreliable, but the major advantage is UDP multicast. You can have one data publisher and many data subscribers. The kernel does the job of delivering a copy of the datagram to each subscriber for you.

Unix local datagram sockets, on the other hand, are required to be reliable but they do not support multicast.

怪异←思 2024-10-22 06:50:51

本地 UDP 比网络上更不可靠,例如 50% 以上的数据包丢失不可靠。这是一个糟糕的选择,内核开发人员将质量归结为缺乏需求。

我建议研究基于消息的中间件,最好使用 BSD 套接字兼容接口,以便于学习。建议使用 ZeroMQ,其中包括 C++、Java 和 Python 绑定。

Local UDP is more unreliable than on a network, like 50%+ packet drop unreliable. It is a terrible choice, kernel developers have attributed the quality down to lack of demand.

I would recommend investigating message based middleware preferably with a BSD socket compatible interface for easy learning curve. A suggestion would be ZeroMQ which includes C++, Java and Python bindings.

生寂 2024-10-22 06:50:51

本地 UDP 仍然不可靠,有时会被防火墙阻止。我们在 MsgConnect 产品中遇到了这个问题,该产品使用本地 UDP 进行线程间通信。 BTW MsgConnect 可以作为您任务的一个选项,这样您就不需要处理套接字。不幸的是,没有 Python 绑定,但存在“本机”C++ 和 Java 实现。

Local UDP is both still unreliable and sometimes blocked by firewalls. We faced this in our MsgConnect product which uses local UDP for interthread communication. BTW MsgConnect can be an option for your task so that you don't need to deal with sockets. Unfortunately there's no Python binding, but "native" C++ and Java implementations exist.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文