I’m using this bit of code to send and receive data, problem is I don’t receive anything..
Code:
US_HOST = "239.255.255.250"
US_PORT = 1900
module SSDP
class Client < EventMachine::Connection
def receive_data data
p "Received some data:"
p data
end
end
end
us = EM.open_datagram_socket US_HOST, US_PORT, SSDP::Client
us.send_data msg
def msg
<<-MSEARCH
M-SEARCH * HTTP/1.1\r
HOST: #{US_HOST}:#{US_PORT}\r
MAN: ssdp:discover\r
MX: 1\r
ST: ssdp:all\r
\r
MSEARCH
end
If I’m sending the exact same message with Ruby’s UDPSocket I do receive data (from the UDPSocket, not from EM)..
Can someone tell me what I’m doing wrong here?
Thanks
This is how i got EventMachine to setup a datagram socket and listen for SSDP announcments.
Change:
To:
You have to actually bind to your ip address and not the multicast address. Then add a constructor to your client class where you tell the socket to join the multicast group for SSDP.