Class: SNMP::UDPServerTransport

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

Instance Method Summary collapse

Constructor Details

#initialize(host, port) ⇒ UDPServerTransport

Returns a new instance of UDPServerTransport.



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

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

Instance Method Details

#closeObject



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

def close
    @socket.close
end

#recvfrom(max_bytes) ⇒ Object



511
512
513
514
515
# File 'lib/snmp/manager.rb', line 511

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

#send(data, host, port) ⇒ Object



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

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