简体   繁体   English

如何在同一台计算机上与两个不同的进程进行通信?

[英]how to make communication with two different process in same computer?

there is two separate processed running on same PC i want to communicate between this two process. 我想在这两个进程之间进行通信,在同一台PC上运行着两个单独的进程。 like pass some data from one process to other . 例如将一些数据从一个进程传递到另一个过程。

WCF

Windows Communication Foundation Windows Communication Foundation

In general you need to implement a client - server architecture and define interface endpoints to communicate between the process that acts as client and the server process. 通常,您需要实现客户端-服务器体系结构并定义接口终结点,以在充当客户端的进程和服务器进程之间进行通信。

The other way is to create a Remotable Class a dynamic library (DLL) so that the same remoted class can be referenced by both the client and the server. 另一种方法是创建动态库(DLL)的可远程类,以便客户端和服务器都可以引用相同的远程类。

The server will have to create instance of the remote class to be able to make sense of the object-oriented data you communicate, and can listen for example on a TCP channel. 服务器将必须创建远程类的实例,以便能够理解您通信的面向对象的数据,并可以在TCP通道上进行侦听。

eg 例如

ChannelServices.RegisterChannel( new TcpChannel( PORT_NUMBER) );       

RemotingServices.Marshal( your_remoted_class, "name_connection" );

Or for local use you can just use the IpcServerChannel API 或者供本地使用,您可以只使用IpcServerChannel API

Now on Client if you used TCP port to listen on for server 现在在客户端上(如果您使用TCP端口侦听服务器)

string remoted_url = "tcp://localhost:<your_port_number>/connection name";

remoted_object = (RemotedClass)RemotingServices.Connect

( typeof(RemotedClass), remoted_url );

The client can now call the public functions through remote_object. 客户端现在可以通过remote_object调用公共功能。

If you are little bit specific about technology, then I could narrow down my answer. 如果您对技术不太了解,那么我可以缩小答案范围。

In a very generic note, these are ways to communicate between two processes. 概括地说,这是在两个流程之间进行通信的方式。

  1. Message communication through a common file. 通过公共文件进行消息通信。
  2. Socket communication between two processes. 两个进程之间的套接字通信。
  3. Mutex 互斥
  4. Any intermediate service. 任何中间服务。

There are several other ways. 还有其他几种方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 同一台计算机上的两个程序之间的通信-如何进行? - Communication between two programs on same computer – How? 是否有 HTTP 的替代方案用于在同一台计算机上处理通信? - Is there an alternative to HTTP for process to process communication on the same computer? 如何在同一程序的两台不同计算机中使用观察者设计模式 - how to use Observers design pattern in two different computer in same program 如何在同一应用程序的两个实例之间进行进程间通信? - How to do inter-process communication between two instances of the same application? 如何建立两个不同EXE之间的通信 - How to establish the communication between the two Different EXEs 如何让两个不同的服务引用实现同一个接口? - How to make two different service references implement the same interface? .NET 远程客户端和服务器在同一台计算机上。 一个过程? 两个过程? - .NET remoting client and server on the same computer. One process? Two processes? 如何在同一网络中具有不同 IP 的设备和计算机上使用 tcplistener 和 tcpclient? - How to use tcplistener and tcpclient on device and computer with different ip in same Network? 两个不同应用程序之间的通信 - Communication between two different applications 为什么使用相同的C#代码在不同计算机上的AD中更改密码会产生不同的速度? - why does using the same c# code to change password in AD in different computer make different speed?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM