Module: ICMP4EM::IcmpHandler

Defined in:
lib/icmp4em/icmp_handler.rb

Instance Method Summary collapse

Instance Method Details

#initialize(args = {}) ⇒ Object



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

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

#notify_readableObject



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

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

#unbindObject



17
18
19
# File 'lib/icmp4em/icmp_handler.rb', line 17

def unbind
  @socket.close if @socket
end