开发者

I'm looking for a network service that'll let me send messages to selected clients

I have a program which will be running on multiple devices on a network. These programs will need to send data between each other - to specified devices (not all devices).

server = server.Server('192.168.1.10')

server.identify('device1')
server.send('device2', 'this will be pickled and sent to device2')
开发者_Python百科

That's some basic example code for what I need to do. Of course, it will also need to receive.

I was looking at building my own simple message passing server using Twisted when someone pointed me in the direction of MPI. I've never looked into the MPI protocol before and that website gives rather vague examples.

Is MPI a good approach? Are there better alternatives?


MPI is really good at doing the communications for running a tightly-coupled program accross several or many machines in a cluster. If you're running very loosely coupled programs - only interacting occasionally - or the machines are more distributed than within a cluster, like scattered around a LAN - then MPI is probably not what you're looking for.


There are several Open Source message brokers that already handle this kind of stuff for you, and come with a full API ready to use.

You should take a look at:

  • ActiveMQ which has a Python Stomp client.
  • RabbitMQ has a Python client too - see Building RabbitMQ apps using Python.

You could build it yourself, but that would be like reinventing the wheel (and on a side-note: I actually only realised I was half-way building a message broker before I started looking at existing solutions - building one takes a lot of work).


Consider using something like ZeroMQ. It supports the most useful messaging idioms - push/pull, publish/subscribe and so on, and although it's not 100% clear from your question which one you need, I'm pretty sure you will find the answer there.

They have a great user guide here, and the Python bindings are well-developed and supported. Some code samples are here.


You can implement MPI functions in order to create a communication between different codes. In this case the server program should public "MPI ports" with differents IDs. Clients should look for this ports and try to connect to them. Only server can accept each communication. Once the communication is stablished, codes can exchange data between them.

Another posibility is to run different programs in Multiple Instruction MPI option. In this case all programs are executed at the same time, and there is not necessity to create port communicators. After they are executed, you can create particular communicators between groups of programms you select.

Please tell me what kind of method you need and I can provide c code to implement the functions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜