Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'socket'
- require 'ipaddr'
- MULTICAST_ADDR = "225.4.5.7"
- PORT = 28960
- ip = IPAddr.new(MULTICAST_ADDR).hton + IPAddr.new("0.0.0.0").hton
- sock = UDPSocket.new
- sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, ip)
- sock.bind(Socket::INADDR_ANY, PORT)
- loop do
- msg, info = sock.recvfrom(1024)
- puts "MSG: #{msg} from #{info[2]} (#{info[3]})/#{info[1]} len #{msg.size}"
- end
Add Comment
Please, Sign In to add comment