Created
July 14, 2013 05:00
-
-
Save clicube/5993268 to your computer and use it in GitHub Desktop.
This file contains 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
require 'socket' | |
require 'thread' | |
query = <<QUERY | |
M-SEARCH * HTTP/1.1 | |
HOST: 239.255.255.250:1900 | |
MAN: "ssdp:discover" | |
MX: 3 | |
ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1 | |
QUERY | |
sock = UDPSocket.open | |
sock.bind("0.0.0.0",1900) | |
thread = Thread.new do | |
loop do | |
puts sock.recv(65535) | |
end | |
end | |
sock.send(query, 0, "239.255.255.250", 1900) | |
sleep 1 | |
thread.kill | |
sock.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment