# Broadcast UDP to address 255.255.255.255 on windows does not work

**URL:** <https://forum.xojo.com/t/broadcast-udp-to-address-255-255-255-255-on-windows-does-not-work/58940>\
**Category:** Windows\
**Created:** [November 19, 2020, 10:18am UTC](https://forum.xojo.com/t/broadcast-udp-to-address-255-255-255-255-on-windows-does-not-work/58940 "2020-11-19T10:18:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hans\_van\_Schaick](https://forum.xojo.com/letter_avatar_proxy/v4/letter/h/bb73d2/32.png) [@Hans\_van\_Schaick](https://forum.xojo.com/u/Hans_van_Schaick)\
**Post date:** [November 19, 2020, 10:18am UTC](https://forum.xojo.com/t/broadcast-udp-to-address-255-255-255-255-on-windows-does-not-work/58940/1 "2020-11-19T10:18:37Z")

</div>

In a small app I need to broadcast a UDP packet to address 255.255.255.255 so that any device connected to the LAN will receive it. (I know this should be done with care, and also I cannot use Multicast)  
This works fine on MacOS and Linux using Xojo UDPSocket and Datagram classes.  
However, on Windows this does not work.

The code could not be simpler. In the run procedure of a console app a buffer is sent using  
"  
Var socket as new UDPSocket  
Var data as new Datagram  
socket.Connect  
data.Address = “255.255.255.255”  
data.port = 1203  
data.Data = buffer  
socket.RouterHops = 64  
socket.Write(data)  
while (socket.PacketsLeftToSend \> 0)  
socket.Poll  
wend  
socket.Close  
"

This has to do with some security issues on Windows. I tried similar code in CSharp which throws an exception on any other address than the current subnet. So the default libraries in Windows do not like 255.255.255.255 as broadcast destination. (Although CSharp even defines ‘IPAddress.Broadcast’ as a synonym for ‘255.255.255.255’.)

Oddly, similar code in Python runs on Windows without a problem and transmits the packet without any issue.

I need to deliver this an executable for Windows and Mac so any pointers to make this work with Xojo on windows is appreciated.

---

<div class="post-metadata">

**Author:** ![anon20074439](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@anon20074439](https://forum.xojo.com/u/anon20074439)\
**Post date:** [November 19, 2020, 10:48am UTC](https://forum.xojo.com/t/broadcast-udp-to-address-255-255-255-255-on-windows-does-not-work/58940/2 "2020-11-19T10:48:18Z")

</div>

I just tested it and it worked fine for me going between my main and a vm using 2020r1.2.

If you post up two simple binary projects (send and receive) I’ll test them here and see if I can spot anything obvious.

---

<div class="post-metadata">

**Author:** ![Hans\_van\_Schaick](https://forum.xojo.com/letter_avatar_proxy/v4/letter/h/bb73d2/32.png) [@Hans\_van\_Schaick](https://forum.xojo.com/u/Hans_van_Schaick)\
**Post date:** [November 19, 2020, 11:22am UTC](https://forum.xojo.com/t/broadcast-udp-to-address-255-255-255-255-on-windows-does-not-work/58940/3 "2020-11-19T11:22:19Z")

</div>

Ok, I have to look again what this issue is. So it must be me… (As usual ;-))

---

<div class="post-metadata">

**Author:** ![Hans\_van\_Schaick](https://forum.xojo.com/letter_avatar_proxy/v4/letter/h/bb73d2/32.png) [@Hans\_van\_Schaick](https://forum.xojo.com/u/Hans_van_Schaick)\
**Post date:** [November 19, 2020, 11:43am UTC](https://forum.xojo.com/t/broadcast-udp-to-address-255-255-255-255-on-windows-does-not-work/58940/4 "2020-11-19T11:43:11Z")

</div>

As usual egg on my face again:

It does work, as long as you filter on the correct ip adres in Wireshark. 🤭  
My VM off course has a different IP address. 🙄

Thanks for pointing out it does work.

This show that one should not always follow your first thought, but take a step backwards before you dig into the issue.

Nothing to do with security and works better than CSharp. Because that does throw an exception. 😉
