Posted to tcl by crshults at Tue Sep 26 04:22:59 GMT 2017view raw

  1. # put this first block into a .tcl file and source into tclsh on the RPi:
  2. package require udp
  3. set sock [udp_open 15351 reuse]
  4. chan configure $sock -blocking 0 -buffering none -remote {255.255.255.255 15351} -broadcast 1
  5. proc read_data {} {puts [chan read $::sock]}
  6. chan event $sock readable read_data
  7. chan puts -nonewline $sock "This is a UDP broadcast message."
  8. proc broadcast {} {chan puts -nonewline $::sock "I am a raspberry pie."; after 2000 broadcast}
  9. broadcast
  10. vwait forever
  11.  
  12. # put this block into a .tcl file and source into tclsh on the Windows box:
  13. package require udp
  14. set sock [udp_open 15351 reuse]
  15. chan configure $sock -blocking 0 -buffering none -remote {255.255.255.255 15351} -broadcast 1
  16. proc read_data {} {puts [chan read $::sock]}
  17. chan event $sock readable read_data
  18. chan puts -nonewline $sock "This is a UDP broadcast message."
  19. proc broadcast {} {chan puts -nonewline $::sock "I am a window."; after 2000 broadcast}
  20. broadcast
  21. vwait forever