class Discovery::Util::UDP::TX

Public Instance Methods

configure() click to toggle source
# File lib/discovery/util/udp.rb, line 48
def configure
  # Set up for multicasting
  @socket.setsockopt Socket::IPPROTO_IP,
                     Socket::IP_MULTICAST_TTL,
                     [1].pack('i')
  # Bind to any available port
  @socket.bind "0.0.0.0", (@bind_port or 0)
end
puts(m) click to toggle source
# File lib/discovery/util/udp.rb, line 57
def puts(m)
  max = UDP.max_length
  if m.size > max
    self.puts m[0...max]
    self.puts m[max...m.size]
  else
    @socket.send(m, 0, @group, @port)
    m
  end
end