发送到Loopback接口的报文收到成功后,我遇到了一个奇怪的问题,但发送到本地网络接口的报文丢失了,从未收到过:
let test (local:IPEndPoint) =
Async.Parallel [
async {
use client = new UdpClient()
client.ExclusiveAddressUse <- false
client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true)
client.Client.Bind(local);
printfn "Listen: %A" local.Address
while true do
let mutable remote = local
client.Receive(&remote) |> ignore
printfn "%A: %A" local.Address remote.Address
};
async {
while true do
do! Async.Sleep 500
use senderUC = new UdpClient()
senderUC.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true)
senderUC.Send([|byte(1)|], 1, local) |> ignore
printfn "sent to %A" local
}
] |> Async.RunSynchronously
// this one works
test(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 5353)) |> ignore
// this one does not
//test(new IPEndPoint(IPAddress.Parse("10.211.55.3"), 5353)) |> ignore
IPCONFIG:
C:\Users\Alex>ipconfig
Windows IP Configuration
Ethernet adapter vEthernet (Intel(R) PRO 1000 MT Network Connection Virtual Switch):
Connection-specific DNS Suffix . : localdomain
IPv4 Address. . . . . . . . . . . : 10.211.55.3
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 10.211.55.1
Wireshark显示发送的数据包(在重新路由到默认网关之后)。
Windows防火墙已关闭。
我不知道该测试什么......
答案 0 :(得分:0)
好吧,5353是Apple Bonjour服务(Zeroconf)。因此,当Bonjour运行时,它会在到达客户端之前捕获这些数据报。在服务中禁用它会将数据包泵送到我的应用程序。