I'm using the following c# code to send out a UDP broadcast. It connects to a Python app which listens for these broadcasts.
UdpClient udpOut = new UdpClient();
udpBeacon = Encoding.ASCII.GetBytes("hello");
udpOut.EnableBroadcast = true;
IPEndPoint udpEp = new IPEndPoint(IPAddress.Broadcast, 7223);
udpOut.Send(udpBeacon, udpBeacon.Length, udpEp);
It works great when both client and server are running on localhost, but I failed to get it to work between two machines connected to WiFi on the same subnet. After some experimentation, this turned out to be because VirtualBox had installed a virtual network adapter and that was all the broadcast was being sent over.
My question is: How do I modify this code to send on all local interfaces? Do I have to manually iterate through Dns.GetHostEntry(Dns.GetHostName()).AddressList and start a connection on each interface?