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

isp*_*iro 2 c# udp

我不知道该如何开始.谷歌搜索后,我在这里找到了这个:

//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);
Run Code Online (Sandbox Code Playgroud)

但我不知道我还需要什么.我从这里尝试了一个示例,但收到一条错误消息:"现有连接被远程主机强行关闭."

我该怎么办?

Chr*_*nte 5

我建议放弃UDP.而是使用命名管道.

它们更可靠.