Skip to content

Instantly share code, notes, and snippets.

@moomindani
Created June 23, 2014 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moomindani/fa64992999602e7075c8 to your computer and use it in GitHub Desktop.
Save moomindani/fa64992999602e7075c8 to your computer and use it in GitHub Desktop.
Receiving mcast
#!/usr/bin/ruby
require "socket"
require "ipaddr"
udps = UDPSocket.open()
udps.bind("0.0.0.0", 10000)
mreq = IPAddr.new("239.192.1.2").hton + IPAddr.new("0.0.0.0").hton
udps.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, mreq)
p udps.recv(65535)
udps.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment