[Newbies] Sending UDP broadcasts

Christian Kellermann ckeen at pestilenz.org
Fri Feb 4 16:32:03 UTC 2022


Hey Tobias!

* Tobias Pape <Das.Linux at gmx.de> [220204 14:46]:
> The host is not a string but rather an address. Try this:
> 
> ```
> addr :=  NetNameResolver addressForName: '255.255.255.255' timeout: 10.
> s := Socket newUDP.
> 
> s setOption:  'SO_BROADCAST' value: 1.
> [[(Delay forSeconds: numberOfSeconds) wait.
> 	 s sendUDPData: shoutout toHost: addr port: (self portNumber) ]
> repeat] fork.
> ```

Oh, duh! Yes of course. I stopped at the <prim> call pragma, I should have gone deeper.
I somehow missed the example in the code.

Another error state for invalid parameters might have helped here in general though.

Thanks for your patience explaining all this.

Cheers,

Christian

-- 
May you be peaceful, may you live in safety, may you be free from
suffering, and may you live with ease. Also encrypt mails to me:
gpg key 0x068757350D0328634B833B65C537678F6BC627B5



More information about the Beginners mailing list