Class: SNMP::UDPTransport

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

Overview

Wrap socket so that it can be easily substituted for testing or for using other transport types (e.g. TCP)

Instance Method Summary collapse

Constructor Details

#initialize(address_family) ⇒ UDPTransport

Returns a new instance of UDPTransport.



40
41
42
# File 'lib/snmp/manager.rb', line 40

def initialize(address_family)
  @socket = UDPSocket.open(address_family)
end

Instance Method Details

#closeObject



44
45
46
# File 'lib/snmp/manager.rb', line 44

def close
  @socket.close
end

#recv(max_bytes) ⇒ Object



52
53
54
# File 'lib/snmp/manager.rb', line 52

def recv(max_bytes)
  @socket.recv(max_bytes)
end

#send(data, host, port) ⇒ Object



48
49
50
# File 'lib/snmp/manager.rb', line 48

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