Skip to content

Instantly share code, notes, and snippets.

@moomindani
Created June 23, 2014 13:01
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/9fd2f1c33f1ba8652476 to your computer and use it in GitHub Desktop.
Save moomindani/9fd2f1c33f1ba8652476 to your computer and use it in GitHub Desktop.
Sending mcast
#!/usr/bin/ruby
require "socket"
require "ipaddr"
udps = UDPSocket.open()
saddr = Socket.pack_sockaddr_in(10000, "239.192.1.2")
mif = IPAddr.new("172.31.4.93").hton
udps.setsockopt(Socket::IPPROTO_IP, Socket::IP_MULTICAST_IF, mif)
udps.send("HELLO", 0, saddr)
udps.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment