M-SEARCH: to which Addr should I send the HTTPMU Response?

Moderator: Praktikum: Internet

fernando
Erstie
Erstie
Beiträge: 17
Registriert: 6. Okt 2006 10:10

M-SEARCH: to which Addr should I send the HTTPMU Response?

Beitrag von fernando » 9. Jan 2008 11:26

Hello,

Today in the Q&A there was a question regarding HTTPMU responses. The specification states: "To be found, a device must send a UDP response to the source IP address and port that sent the request to the multicast channel" .

The specification is correct, but can be confusing. Here's a code example of what it means:

// These are for ref. **ONLY** (To understand the example). Must be initialized!

Code: Alles auswählen

        public MulticastSocket multicastSendSocket, multicastReceiveSocket;
        public DatagramPacket input; 


// code example begins here...

Code: Alles auswählen

multicastReceiveSocket.receive(input);   

SocketAddress from = input.getSocketAddress(); //IP address and port that sent the m_cast request
adr = (InetSocketAddress) from;

if (!adr.equals(multicastSendSocket.getLocalSocketAddress())) {  //Is it my own event?
 //process M-SEARCH event
 }
Regards,
Fernando

Zurück zu „Praktikum: Internet“