Class: SNMP::UDPServerTransport

Inherits:
Object
  • Object
show all
Defined in:
lib/cosmos/io/cosmos_snmp.rb

Instance Method Summary collapse

Instance Method Details

#recvfrom(max_bytes) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cosmos/io/cosmos_snmp.rb', line 36

def recvfrom(max_bytes)
  # Implement blocking using recvfrom_nonblock to prevent potential
  # ruby thread deadlock
  begin
    data, host_info = @socket.recvfrom_nonblock(max_bytes)
  rescue Errno::EAGAIN, Errno::EWOULDBLOCK
    IO.fast_select([@socket])
    retry
  end
  flags, host_port, host_name, host_ip = host_info
  return data, host_ip, host_port
end