Class: SNMP::UDPServerTransport

Inherits:
Object
  • Object
show all
Defined in:
lib/snmp/manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(host, port, address_family) ⇒ UDPServerTransport

Returns a new instance of UDPServerTransport.



541
542
543
544
# File 'lib/snmp/manager.rb', line 541

def initialize(host, port, address_family)
  @socket = UDPSocket.open(address_family)
  @socket.bind(host, port)
end

Instance Method Details

#closeObject



546
547
548
# File 'lib/snmp/manager.rb', line 546

def close
  @socket.close
end

#recvfrom(max_bytes) ⇒ Object



554
555
556
557
558
# File 'lib/snmp/manager.rb', line 554

def recvfrom(max_bytes)
  data, host_info = @socket.recvfrom(max_bytes)
  _, host_port, _, host_ip = host_info
  return data, host_ip, host_port
end

#send(data, host, port) ⇒ Object



550
551
552
# File 'lib/snmp/manager.rb', line 550

def send(data, host, port)
  @socket.send(data, 0, host, port)
end