Class: SNMP::UDPServerTransport

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

Instance Method Summary collapse

Constructor Details

#initialize(port) ⇒ UDPServerTransport

Returns a new instance of UDPServerTransport.



497
498
499
500
# File 'lib/snmp/manager.rb', line 497

def initialize(port)
    @socket = UDPSocket.open
    @socket.bind('localhost', port)
end

Instance Method Details

#closeObject



502
503
504
# File 'lib/snmp/manager.rb', line 502

def close
    @socket.close
end

#recvfrom(max_bytes) ⇒ Object



506
507
508
509
510
# File 'lib/snmp/manager.rb', line 506

def recvfrom(max_bytes)
    data, host_info = @socket.recvfrom(max_bytes)
    flags, host_socket, host_name, host_ip = host_info
    return data, host_ip
end