Created
February 2, 2019 22:44
-
-
Save daniel12fsp/6f57f240e8e15e81af4161130d5610a6 to your computer and use it in GitHub Desktop.
Simple SSDP 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
| const dgram = require('dgram'); | |
| const search = new Buffer([ | |
| 'M-SEARCH * HTTP/1.1', | |
| 'HOST: 239.255.255.250:1900', | |
| 'MAN: "ssdp:discover"', | |
| 'MX: 3', | |
| 'ST: ssdp:all' | |
| ].join('\r\n')); | |
| const socket = dgram.createSocket('udp4'); | |
| socket.on('listening', () => { | |
| socket.addMembership('239.255.255.250'); | |
| socket.send(search, 0, search.length, 1900, "239.255.255.250"); | |
| }); | |
| socket.on('message', (message) => { | |
| console.log(message.toString()); | |
| }); | |
| socket.bind(1900); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment