使用共享内存通信btw 2 pc?

时间:2021-06-01 13:24:06

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?

我必须构建一个概念,使用共享内存或tcp套接字编程概念在两台计算机之间进行通信。我会怎么做呢?是否有可能在客户端服务器架构中实现共享内存?我该如何解决?

6 个解决方案

#1


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

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

You should use TCP sockets.

您应该使用TCP套接字。

#2


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

您可以与具有共享内存的远程系统通信。远程DMA是较新的高性能网络接口控制器卡(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? :)

这是一篇评估10 Gb以太网RDMA性能的论文。我知道infinaband也可以RDMA,其他可能。当802.11 XXX问世时,它会不会很好?无线RDMA? :)

#3


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.

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

#4


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.

搜索“分布式缓存”“元组空间”和“分布式共享内存”它可能提供一些思考的东西。 memcached是一个非常受欢迎的开源产品,你可以看看。

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.

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

#5


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

您可能希望查看像memcached这样的分布式内存对象缓存系统。

Granted, this is still done via TCP.

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

#6


I recommend Beej's guide to Network Programming.

我推荐Beej的网络编程指南。

#1


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

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

You should use TCP sockets.

您应该使用TCP套接字。

#2


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

您可以与具有共享内存的远程系统通信。远程DMA是较新的高性能网络接口控制器卡(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? :)

这是一篇评估10 Gb以太网RDMA性能的论文。我知道infinaband也可以RDMA,其他可能。当802.11 XXX问世时,它会不会很好?无线RDMA? :)

#3


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.

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

#4


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.

搜索“分布式缓存”“元组空间”和“分布式共享内存”它可能提供一些思考的东西。 memcached是一个非常受欢迎的开源产品,你可以看看。

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.

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

#5


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

您可能希望查看像memcached这样的分布式内存对象缓存系统。

Granted, this is still done via TCP.

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

#6


I recommend Beej's guide to Network Programming.

我推荐Beej的网络编程指南。