RPC和IPC的区别

RPC:

http://en.wikipedia.org/wiki/Remote_procedure_call

Incomputer science, aremote procedure call(RPC) is aninter-process communicationthat allows acomputer programto cause asubroutineor procedure to execute in anotheraddress space(commonly on another computer on a shared network) without the programmer explicitly coding the details for this remote interaction. That is, the programmer writes essentially the same code whether the subroutine is local to the executing program, or remote. When the software in question usesobject-orientedprinciples, RPC is calledremote invocationorremote method invocation.

IPC: http://en.wikipedia.org/wiki/Inter-process_communication

Incomputing,inter-process communication(IPC) is a set of methods for the exchange of data among multiplethreadsin one or moreprocesses. Processes may be running on one or more computers connected by anetwork. IPC methods are divided into methods formessage passing,synchronization,shared memory, andremote procedure calls(RPC). The method of IPC used may vary based on the bandwidth and latency of communication between the threads, and the type of data being communicated.

There are several reasons for providing an environment that allows process cooperation:

  • Information sharing
  • Computational speedup
  • Modularity
  • Convenience
  • Privilege separation

IPC may also be referred to asinter-thread communicationandinter-application communication.

可见,RPC是IPC的一种。


RMI和RPC之间最主要的区别在于方法是如何别调用的。在RMI中,远程接口使每个远程方法都具有方法签名。如果一个方法在服务器上执行,但是没有相匹配的签名被添加到这个远程接口上,那么这个新方法就不能被RMI客户方所调用。在RPC中,当一个请求到达RPC服务器时,这个请求就包含了一个参数集和一个文本值,通常形成“classname.methodname”的形式。这就向RPC服务器表明,被请求的方法在为“classname”的类中,名叫“methodname”。然后RPC服务器就去搜索与之相匹配的类和方法,并把它作为那种方法参数类型的输入。这里的参数类型是与RPC请求中的类型是匹配的。一旦匹配成功,这个方法就被调用了,其结果被编码后返回客户方。

你可能感兴趣的:(RPC和IPC的区别)