Created
December 9, 2010 02:40
-
-
Save koleto/734262 to your computer and use it in GitHub Desktop.
UPnP search
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
package require udp | |
set count 0 | |
# A SSDP multicast demo. | |
proc udpEvent {chan} { | |
global count | |
set data [read $chan] | |
set peer [fconfigure $chan -peer] | |
puts "=================== $count =========================" | |
set count [expr $count + 1] | |
puts "$peer [string length $data] $data" | |
return | |
} | |
set group 239.255.255.250 | |
set port 1900 | |
global s | |
set s [udp_open $port] | |
fconfigure $s -buffering none -blocking 0 | |
fconfigure $s -mcastadd $group -remote [list $group $port] | |
fileevent $s readable [list udpEvent $s] | |
puts -nonewline $s "M-SEARCH * HTTP/1.1\r\nMX: 3\r\nHOST: 239.255.255.250:1900\r\nMAN: \"ssdp:discover\"\r\nST: upnp:rootdevice\r\n\r\n" | |
#puts -nonewline $s "M-SEARCH * HTTP/1.1\r\nMX: 3\r\nHOST: 239.255.255.250:1900\r\nMAN: \"ssdp:discover\"\r\nST: ssdp:all\r\n\r\n" | |
set ::forever 0 | |
vwait ::forever | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment