简体   繁体   English

同一台计算机上的两个程序之间的通信-如何进行?

[英]Communication between two programs on same computer – How?

I don't know how to begin. 我不知道该如何开始。 After Googling, I've found this here : 谷歌搜索后,我在这里找到

//This is how you do it (kudos to sipwiz)
UdpClient udpServer = new UdpClient(localpt); 

//This is what the proprietary (see question) sender would do (nothing special) 
//!!! The following 3 lines is what the poster needs...
//(and the definition of localpt, of course)
UdpClient udpServer2 = new UdpClient();
udpServer2.Client.SetSocketOption(
    SocketOptionLevel.Socket,
    SocketOptionName.ReuseAddress, true);

udpServer2.Client.Bind(localpt);

But I don't know what else I need. 但是我不知道我还需要什么。 I tried an example from here , but got an error message: "An existing connection was forcibly closed by the remote host." 我从此处尝试了一个示例,但收到一条错误消息: “现有连接被远程主机强行关闭。”

How do I proceed? 我该怎么办?

I'd suggest ditching UDP. 我建议放弃UDP。 Instead, use Named Pipes . 而是使用命名管道

They are more reliable. 它们更可靠。

我认为最好将WCF与命名管道绑定一起使用

Named pipe is the best option on the same system. 命名管道是同一系统上的最佳选择。 Due the fact that the performance is better then TCP cause the traffic is not using the network interfaces. 由于性能好于TCP,因此导致流量未使用网络接口。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM