daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Nov 24th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require 'socket'
  2. require 'ipaddr'
  3.  
  4. MULTICAST_ADDR = "225.4.5.7"
  5. PORT = 28960
  6.  
  7. ip =  IPAddr.new(MULTICAST_ADDR).hton + IPAddr.new("0.0.0.0").hton
  8.  
  9. sock = UDPSocket.new
  10. sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, ip)
  11. sock.bind(Socket::INADDR_ANY, PORT)
  12.  
  13. loop do
  14.   msg, info = sock.recvfrom(1024)
  15.   puts "MSG: #{msg} from #{info[2]} (#{info[3]})/#{info[1]} len #{msg.size}"
  16. end
RAW Paste Data
Top