同一台计算机上的两个程序之间的通信如何?
我不知道如何开始。谷歌搜索后,我发现了这个 这里:
//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);
但我不知道我还需要什么。我尝试了此处中的示例,但收到错误消息:< em>“现有连接被远程主机强制关闭。”
我该如何继续?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议放弃 UDP。请改用命名管道。
他们更可靠。
I'd suggest ditching UDP. Instead, use Named Pipes.
They are more reliable.
我认为最好将 WCF 与命名管道绑定一起使用
I think it's better to use WCF with Named Pipe binding
命名管道是同一系统上的最佳选择。
由于性能优于 TCP,因为流量不使用网络接口。
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.