I have a strange issue when the packets sent to loopback interface are received successfully, but the same packets sent to the local network interface are lost and never received:
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 shows the packets sending (after re-routing to the default gateway).
Windows firewall is turned off.
I have no idea what to test...
Well, 5353 is Apple Bonjour service (Zeroconf). So while Bonjour is running it captures these datagrams before they reach the client. Disabling it in Services pumps the packet to my app.