I tested your program. Works very fine! But there is a little bug in the code.
This is the code used for detecting a search request:
if (request.indexOf('M-SEARCH') > 0) {if (request.indexOf("urn:Belkin:device:**") > 0) {...
The first indexOf gives a warning "To many chars in char constant". It is compiled to "indexOf('M')". Replacing it with indexOf("M-SEARCH") does not work, because "M-SEARCH" is at position 0. indexOf() returns -1 if a string is not found!
Replace the code by
if (request.indexOf('M-SEARCH') > -1) {if (request.indexOf("urn:Belkin:device:**") > -1) {...
or
if (request.indexOf('M-SEARCH') == 0) {if (request.indexOf("urn:Belkin:device:**") > -1) {...
I tested your program. Works very fine! But there is a little bug in the code.
This is the code used for detecting a search request:
if (request.indexOf('M-SEARCH') > 0) {
if (request.indexOf("urn:Belkin:device:**") > 0) {
...
The first indexOf gives a warning "To many chars in char constant". It is compiled to "indexOf('M')". Replacing it with indexOf("M-SEARCH") does not work, because "M-SEARCH" is at position 0. indexOf() returns -1 if a string is not found!
Replace the code by
if (request.indexOf('M-SEARCH') > -1) {
if (request.indexOf("urn:Belkin:device:**") > -1) {
...
or
if (request.indexOf('M-SEARCH') == 0) {
if (request.indexOf("urn:Belkin:device:**") > -1) {
...