EDIT: Based on Firefox OS.
Looking around about this topic and based on André Fiedler answer I found that the libraries he posted about resides on UDPSocket
from MDN webarchive.
In the main page you can see the discovery example:
var SSDP_PORT = 1900;
var SSDP_ADDRESS = "239.255.255.250";
var SSDP_DISCOVER_MX = 2;
var SEARCH_TARGET = "urn:schemas-upnp-org:service:ContentDirectory:1";
var SSDP_DISCOVER_PACKET =
"M-SEARCH * HTTP/1.1\r\n" +
"HOST: " + SSDP_ADDRESS + ":" + SSDP_PORT + "\r\n" +
"MAN: \"ssdp:discover\"\r\n" +
"MX: " + SSDP_DISCOVER_MX + "\r\n" +
"ST: " + SEARCH_TARGET + "\r\n" +
"\r\n";
var searchSocket = new UDPSocket({
loopback: true
});
searchSocket.joinMulticastGroup(SSDP_ADDRESS);
searchSocket.onmessage = function (e) {
var msg = String.fromCharCode.apply(null, new Uint8Array(e.data));
console.log(msg);
};
searchSocket.opened.then(function() {
searchSocket.send(SSDP_DISCOVER_PACKET, SSDP_ADDRESS, SSDP_PORT);
setTimeout(function () { searchSocket.close(); }, SSDP_DISCOVER_MX * 1000);
});