Last active
February 24, 2017 00:15
-
-
Save gchiu/0c26eddfdb89a688445e0167ef004d76 to your computer and use it in GitHub Desktop.
testing ssdp listen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Rebol [ | |
| file: %ssdp-server.reb | |
| ] | |
| serve-udp: open udp://:1900 | |
| serve-udp/awake: func [evt][ | |
| ; print ["multicast event:" evt/type " on " evt/port/spec/port-id " at " now/precise] | |
| ; probe query evt/port | |
| print ["Event received on UDP ===>" evt/type] | |
| switch/default evt/type [ | |
| read [ | |
| print ["read server data:" newline to-string evt/port/data] | |
| clear evt/port/data | |
| read evt/port | |
| ] | |
| error [ | |
| return false | |
| ] | |
| ][return false] | |
| ] | |
| set-udp-multicast serve-udp 239.255.255.250 0.0.0.0 | |
| set-udp-ttl serve-udp 1 | |
| wait-ports: copy [] | |
| append wait-ports serve-udp | |
| print "Listening ..." | |
| ; read serve-udp ; seems to be necessary | |
| serve-udp/awake make event! [type: 'read port: serve-udp] | |
| print ["start wait at " now/precise] | |
| wait wait-ports |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment