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.



370
371
372
373
# File 'lib/snmp/manager.rb', line 370

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

Instance Method Details

#closeObject



375
376
377
# File 'lib/snmp/manager.rb', line 375

def close
    @socket.close
end

#recvfrom(max_bytes) ⇒ Object



379
380
381
382
383
# File 'lib/snmp/manager.rb', line 379

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