![](/img/trans.png)
[英]Sending and receiving UDP packets between two programs on the same computer
[英]Communication between two programs on same computer – How?
//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);
但是我不知道我還需要什么。 我從此處嘗試了一個示例,但收到一條錯誤消息: “現有連接被遠程主機強行關閉。”
我該怎么辦?
我建議放棄UDP。 而是使用命名管道 。
它們更可靠。
我認為最好將WCF與命名管道綁定一起使用
命名管道是同一系統上的最佳選擇。 由於性能好於TCP,因此導致流量未使用網絡接口。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.