I have a network of computers(25 of them). all in the 10.0.0.(1-200) local network IP range.
When I use
UDPSocket1.BroadcastAddress and send out a datagram it works fine from all of the computers but one, which wont send a UDP broadcast.
No error is generated, it just doesnt send it.
This computer will happily send a UDP datagram to another distinct IP ie 10.0.0.116 , but when the address is the broadcast address, it doesnt send.
It can receive UDP broadcasts from other computers fine.
Any ideas? I suspect some firewall setting thats blocking UDP broadcasts from being sent, but letting normally addressed UDP datagrams through.
Also is the UDPSocket1.BroadcastAddress always 255.255.255.255 ???
I can get around it by just spamming the address space as its small, ie have a loop that sends the message to 10.0.0.1 , then 10.0.0.2 , 10.0.0.3 etc
As its a fast network and the message is small its not a big deal.
Sort of solved, if I use an address of 10.255.255.255 thats works fine, But UDPSocket1.BroadcastAddress returns 255.255.255.255 which is blocked.
Using wireshark, I can see drop box using 10.255.255.255 , so I’m guessing thats the Broadcast address I should use.
As I need this work on any small network, Ill have to find a way of calculating the broadcast address.
Is this a XOJO bug? or am I missing something here.
The method for calculating a specific broadcast address isnt too difficult. But keep in mind, the reason we use 255.255.255.255 by default is that its not routable. That means that on a corporate network where there may be many different subnets connected by routers, your UDP broadcasts will never leave the network you are on.
Ok, now for the calculation:
In your case its pretty simple. Any places you have a 0 in the subnet mask, you replace it with a 255 in the IP address.
If your subnet mask is more specific (not an even 0 or 255) youd need to do some bitwise operations.
Thanks Greg, ! I think I will use the default broadcast , and use the calculated broadcast address and resend on that. Creats a little more network traffic but more robust. Thanks for the code snippet, very clear !