class Discovery::Util::UDP::Xceiver
Attributes
group[R]
local_ip[R]
local_port[R]
port[R]
socket[R]
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/discovery/util/udp.rb, line 15 def self.new(*args) if (self.class==Xceiver) raise TypeError, "#{self.class} is an 'abstract class' only."\ " Inherit it; don't instantiate it!"; end super end
new(group, port, **kwargs)
click to toggle source
# File lib/discovery/util/udp.rb, line 22 def initialize(group, port, **kwargs) @group = group @port = port kwargs.each_pair { |k,v| instance_variable_set("@#{k}".to_sym, v) } open end
Public Instance Methods
close()
click to toggle source
# File lib/discovery/util/udp.rb, line 40 def close @socket.close if @socket @socket = nil end
open()
click to toggle source
# File lib/discovery/util/udp.rb, line 29 def open @socket.close if @socket @socket = UDPSocket.new configure @local_ip = Socket.ip_address_list.detect{|intf| intf.ipv4_private?} @local_port = @socket.addr[1] return @socket ensure @finalizer ||= ObjectSpace.define_finalizer self, Proc.new { close } end