Module: ICMP4EM::UdpHandler

Defined in:
lib/icmp4em/udp_handler.rb

Instance Method Summary collapse

Instance Method Details

#initialize(args = {}) ⇒ Object



3
4
5
# File 'lib/icmp4em/udp_handler.rb', line 3

def initialize args = {}
  @manager = args[:manager]
end

#notify_readableObject



7
8
9
10
11
12
13
14
# File 'lib/icmp4em/udp_handler.rb', line 7

def notify_readable
  data, host = @io.recvfrom(1500)
  
  begin
    @manager.handle_reply Packet.from_bytes(data)
  rescue ArgumentError
  end
end

#unbindObject



16
17
18
# File 'lib/icmp4em/udp_handler.rb', line 16

def unbind
  @socket.close if @socket
end