顺便说一句,两台电脑使用共享内存进行通信吗?

发布于 2024-07-17 02:33:26 字数 86 浏览 5 评论 0原文

我必须建立一个概念,使用共享内存或 TCP 套接字编程概念在两台计算机之间进行通信。我该如何去做?是否可以在客户端服务器体系结构中实现共享内存?我该如何去做?

i have to build a concept to communicate between two computers using shared memory or tcp socket programming concepts..how do i go about it?is it possible to implement shared memory in a client server architecture?how do i go about it?

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

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

发布评论

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

评论(6

花落人断肠 2024-07-24 02:33:26

您无法使用共享内存在两台计算机之间进行通信,因为它们不共享内存。

您应该使用 TCP 套接字。

You can't communicate between two computers using shared memory, because they don't share memory.

You should use TCP sockets.

毁虫ゝ 2024-07-24 02:33:26

可以通过共享内存与远程系统进行通信。远程DMA是较新的高性能网络接口控制器卡(NIC)的一项功能。

这是一篇评估 10 Gb 以太网 RDMA 性能的论文。 我知道 infinaband 也可以 RDMA,其他也可能。 802.11 XXX 出来了不是很好吗? 无线 RDMA? :)

You CAN communicate with a remote system with shared memory. Remote DMA is a feature of newer high performance network interface controller cards (NIC).

Here's a paper which evaluated 10 Gb ethernet RDMA performance. I know infinaband can also RDMA, others likely. Won't it be nice when 802.11 XXX comes out? Wireless RDMA? :)

混浊又暗下来 2024-07-24 02:33:26

我认为您所寻找的不是共享内存,更恰当地称为“反射记忆”之类的东西。

使用反射内存块,网络上的每台计算机都拥有一个内存块。 每个块都以高速在所有计算机之间的总线上传输。 每台计算机从所有其他计算机获取内存的副本以供读取,但通常只能写入自己的内存。

因此,每台计算机都可以“看到”其他计算机中的内存状态。 通常,您会在工业控制系统中看到这种架构,这些系统将控制权分布在物理上独立的机器上,并且希望近乎实时地查看整体状态。

至于构建系统,您可以从 UDP 数据包开始,这些数据包只是爆出本地计算机的状态,并让所有其他计算机读取该数据。

I think rather than shared memory, what you are looking for is more properly called something like "reflective memory".

With Reflective Memory blocks each computer on the network owns a block of memory. Every block is punted around a bus between all the computers at a high rate of speed. Each computer gets a copy of the memory from all other computers for reading, but typically can only write to its own memory.

Thus each computer can "see" the state of the memory in every other computer. Typically you see this sort of architecture in industrial control systems that distribute the control over physically separate machines and want to see the overall state in near real-time.

As for building a system, well you could start with UDP packets that just blast out the state of the local computer and have all the other computers read that data.

本王不退位尔等都是臣 2024-07-24 02:33:26

尖锐的答案“你不能这样做,因为计算机不共享内存”是完全错误的。 单个计算机内的处理器不共享内存,硬件和软件实现共享内存协议以提供共享内存的假象。

跨处理器的共享内存协议与跨计算机的共享内存协议非常相似,有同样的问题。

搜索“分布式缓存”“元组空间”和“分布式共享内存”它可能会提供一些值得深思。 memcached 是一个非常流行的开源产品,您可以看看。

编辑:关于“缓存一致性架构”的评论。 每个处理器都有自己的本地内存缓存(例如 L1 缓存)。 有一大堆“东西”恰好使这个“缓存一致”,这样看起来每个处理器都在读取和写入共享内存空间。 处理器绝对不会直接写入单个共享内存空间。 从概念上讲,这个问题对于跨计算机的共享内存来说是相同的。

The snarky answer "you can't do it because computers don't share memory" is just plain wrong. Processors within a single computer do not share memory, the hardware and software implement shared memory protocols to provide an illusion of shared memory.

Shared memory protocols across processors are very similar to shared memory protocols across computers, its the same problem.

Search for "distributed cache" "tuple space" and "distributed shared memory" it might provide some food for thought. memcached is a very popular open source product you can take a look at.

EDIT: Regarding the comment about "cache coherent architecture". Each processor has its own local cache of memory (L1 cache for example). There is a whole bunch of "stuff" that happens to make this "cache coherent" so that it appears each processor is reading and writing to a shared memory space. The processors are absolutely, positively not writing directly to a single shared memory space. The problem is conceptually the same for shared memory across computers.

梨涡少年 2024-07-24 02:33:26

您可能想研究一下 memcached 之类的东西,这是一种分布式内存对象缓存系统。

当然,这仍然是通过 TCP 完成的。

You may want to look into something like memcached, a distributed memory object caching system.

Granted, this is still done via TCP.

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