进程间通信的方法 [英] Approaches of interprocess communication

查看:52
本文介绍了进程间通信的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


假设您在同一个盒子上运行了两个独立的进程,

您建议在这两个进程之间进行通信的方法是什么? />
流程。


让我列出我所知道的:


*套接字

优点:几乎每种编程语言本身都支持

甚至不需要安装额外的软件包

缺点:很多代码要写,而且''如果进程在同一台机器上运行,那么通过TCP / IP进行通信就很傻了。


* Webservices

优势:相对容易使用,可以跨越不同的工作

语言

缺点:在TCP / IP端更简单的开销那个简单的

套接字,因为需要传递非常庞大的SOAP消息。


* CORBA - 类似于webservices但代码更复杂。


*共享记忆

我不太了解关于这个主题。


假设这两个进程都是用Python编写的,还有其他方法

来实现这个目标吗?对我来说,共享内存听起来是最合适的方法。

但是如上所述,我仍然在这方面模糊。哪里可以找到关于这个主题的更多信息?

Hi all,

Supposing you have two separate processes running on the same box,
what approach would you suggest to communicate between those two
processes.

Let me list the ones I know of:

* Sockets
Advantage: Supported per se in nearly every programming language
without even the need to install additional packages
Disadvantage: Lot''s of code to write, and it''s kind of silly to
communicate via TCP/IP if the processes run on the same machine.

* Webservices
Advantage: Relatively easy to use, can work across different
languages
Disadvantage: Even more overhead on the TCP/IP side that simple
sockets, as really bulky SOAP messages need to be passed around.

* CORBA -- similar to webservices but more complicated to code.

* Shared memory
I don''t know much about this subject.

Supposing both processes are written in Python, is there any other way
to achieve this? To me, shared memory sound the most suited approach.
But as said, I am still fuzzy in this area. Where can I find more
information on this subject?

推荐答案

En Fri,2007年2月16日07 :11:36 -0300,exhuma.twn< ex **** @gmail.comescribió:
En Fri, 16 Feb 2007 07:11:36 -0300, exhuma.twn <ex****@gmail.comescribió:

大家好,


假设您在同一个盒子上运行了两个独立的进程,

您建议在这两个

进程之间进行通信的方法。

让我列出我所知道的:


*套接字

优势:几乎所有编程语言本身都支持

甚至不需要安装额外的套餐

缺点:很多代码要编写,而且有点傻〜

通过如果进程在同一台机器上运行,则为TCP / IP。
Hi all,

Supposing you have two separate processes running on the same box,
what approach would you suggest to communicate between those two
processes.

Let me list the ones I know of:

* Sockets
Advantage: Supported per se in nearly every programming language
without even the need to install additional packages
Disadvantage: Lot''s of code to write, and it''s kind of silly to
communicate via TCP/IP if the processes run on the same machine.



没有那么多代码,真的。

(我希望与localhost建立连接实际上是

* not *下到网卡硬件层,但我不知道

如果是这样的话是真实的。

Not so much code, really.
(And I would expect that making a connection to "localhost" actually does
*not* go down up to the network card hardware layer, but I don''t know for
real if this is the case or not).


* Webservices

优点:相对容易使用,可以跨越不同的工作

语言

缺点: TCP / IP端的开销就更简单了,因为需要传递非常庞大的SOAP消息。
* Webservices
Advantage: Relatively easy to use, can work across different
languages
Disadvantage: Even more overhead on the TCP/IP side that simple
sockets, as really bulky SOAP messages need to be passed around.



您可以使用XMLRPC,它更简单(但功能更弱)。

You could use XMLRPC, wich is a lot simpler (but less powerful).


* CORBA - 类似于webservices,但代码更复杂。
* CORBA -- similar to webservices but more complicated to code.



我会尽可能远离。

I would stay away as far as I could.


*共享内存

我对这个问题了解不多。
* Shared memory
I don''t know much about this subject.



你忘了最基本的一个,stdio重定向。很容易,几乎任何语言都可以使用

,但仅限于一对进程。

你可以添加队列和消息。

You forget the most basic one, stdio redirection. Easy, available on
almost any language, but limited to just a pair of processes.
You can add queues and messages.


假设两个进程都是用Python编写的,还有其他方式

来实现这个目标吗?对我来说,共享内存听起来是最合适的方法。

但是如上所述,我仍然在这方面模糊。我在哪里可以找到更多关于这个主题的信息?
Supposing both processes are written in Python, is there any other way
to achieve this? To me, shared memory sound the most suited approach.
But as said, I am still fuzzy in this area. Where can I find more
information on this subject?



Pyro似乎是一个不错的选择(尽管我还没用过它)。


-

Gabriel Genellina

Pyro appears to be a good alternative (altough I''ve never used it yet).

--
Gabriel Genellina


假设您在同一个盒子上运行了两个独立的进程,
Supposing you have two separate processes running on the same box,

你建议在这两个

流程之间进行沟通。


让我列出我所知道的:


*套接字

优势:几乎所有编程语言本身都支持

甚至无需安装额外的软件包

缺点:很多代码要编写,如果进程在同一台机器上运行,那么通过TCP / IP进行通信是很愚蠢的。
< br $>
* Webservices

优点:相对容易使用,可以跨越不同的工作

语言

缺点:更多的开销在TCP / IP方面这简单

套接字,因为需要传递非常庞大的SOAP消息。


* CORBA - 类似于webservices但代码更复杂。


*共享内存

我对这个主题了解不多。


假设两个进程都是用Python编写的,还有其他方法吗? >
来实现这个目标?对我来说,共享内存听起来是最合适的方法。

但是如上所述,我仍然在这方面模糊。我在哪里可以找到更多关于这个主题的信息?
what approach would you suggest to communicate between those two
processes.

Let me list the ones I know of:

* Sockets
Advantage: Supported per se in nearly every programming language
without even the need to install additional packages
Disadvantage: Lot''s of code to write, and it''s kind of silly to
communicate via TCP/IP if the processes run on the same machine.

* Webservices
Advantage: Relatively easy to use, can work across different
languages
Disadvantage: Even more overhead on the TCP/IP side that simple
sockets, as really bulky SOAP messages need to be passed around.

* CORBA -- similar to webservices but more complicated to code.

* Shared memory
I don''t know much about this subject.

Supposing both processes are written in Python, is there any other way
to achieve this? To me, shared memory sound the most suited approach.
But as said, I am still fuzzy in this area. Where can I find more
information on this subject?



您好,如果您的要求足够轻,那么pylinda可能是一个易于使用的解决方案:

http://www-users.cs。 york.ac.uk/~aw/pylinda/


这里有一个简单的例子:

http://www-users.cs.york.ac.uk/~aw /p.../beginner.html


HTH,

Daniel

Hi, if your requirements are sufficiently light then pylinda might be
an easy-to-use solution:

http://www-users.cs.york.ac.uk/~aw/pylinda/

A simple example is here:

http://www-users.cs.york.ac.uk/~aw/p.../beginner.html

HTH,
Daniel


" exhuma.twn" < ex **** @ gmail.comwrites:
"exhuma.twn" <ex****@gmail.comwrites:

假设你有两个独立的进程在同一个盒子上运行,

是什么方法你会建议在这两个

流程之间进行沟通。


让我列出我所知道的:


*套接字

优势:几乎所有编程语言本身都支持

甚至不需要安装额外的软件包
Supposing you have two separate processes running on the same box,
what approach would you suggest to communicate between those two
processes.

Let me list the ones I know of:

* Sockets
Advantage: Supported per se in nearly every programming language
without even the need to install additional packages



这是我的选择。但首先,为两个进程设置一个明确定义的*协议*

(最好基于文本命令),用于

通信;不要让他们每个人都错综复杂地意识到每个人的实施。

This would be my choice. But first, set up a well-defined *protocol*
(preferably based on text commands) for the two processes to use for
communication; don''t have each of them being intricately aware of each
others'' implementation.


缺点:很多代码如果进程在同一台机器上运行,那么通过TCP / IP进行通信是很愚蠢的。
Disadvantage: Lot''s of code to write, and it''s kind of silly to
communicate via TCP/IP if the processes run on the same machine.



您可以使用标准库来减少代码数量

" cmd"用于处理命令接口的模块,将命令行处理程序的stdin和

stdout挂接到套接字。


如果您已经在考虑合作进程你应该从一开始就把它们视为网络中立。


这就是_The Unix编程的艺术_必须说的主题是

文本协议:


< URL:http://www.catb.org/~esr/writings/taoup/html/ch05s01.html>


和对等流程的IPC策略:


< URL:http://www.catb.org/~esr/writings/ taoup / html / ch07s07.html>


-

\只有两种方式过你的生活。一个是好像|

` \没有什么是奇迹。另一种就好像一切都是。 - |

_o__)阿尔伯特爱因斯坦|

Ben Finney

You can cut down on the amount of code by using the standard library
"cmd" module to handle a command interface, hooking the stdin and
stdout of the commandline handler to the socket.

If you''re already thinking about cooperating processes, you should
make them network-neutral anyway from the start.

Here''s what _The Art of Unix Programming_ has to say on the topic of
text protocols:

<URL:http://www.catb.org/~esr/writings/taoup/html/ch05s01.html>

and IPC tactics for peer processes:

<URL:http://www.catb.org/~esr/writings/taoup/html/ch07s07.html>

--
\ "There are only two ways to live your life. One is as though |
`\ nothing is a miracle. The other is as if everything is." -- |
_o__) Albert Einstein |
Ben Finney


这篇关于进程间通信的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆