I'm connecting to a system that sends UDP packets, both as responses (sent to a specific IP address) and as broadcasts (dest 255.255.255.255, according to WireShark)
I can receive the 'direct' packets correctly, but I can't work out how to get the broadcast ones. I assume I need a second TIdUDPClient with different bindings, but I haven't been able to get it working.
TIdUDPClient *reader(new TIdUDPClient(NULL));
TIdUDPClient *broadcastReader(new TIdUDPClient(NULL));
reader->Port = 2000;
reader->Host = "192.168.0.1";
reader->Connect();
broadcastReader->Port = 2000;
// broadcastReader->Host = "0.0.0.0"; // This doesn't work, but is here as an example
broadcastReader->BroadcastEnabled = true;
broadcastReader->Connect();
I then have other near-identical threads calling reader/broadcastReader->ReceiveBuffer(). The reader one works fine, but broadcastReader->receiveBuffer() never returns...
Apologies for C++ code and a Delphi tag ;-)
TIdUDPClient is not designed for receiving broadcasts. Use TIdUDPServer instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With