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

#initializeUDPTransport

Returns a new instance of UDPTransport.



25
26
27
# File 'lib/snmp/manager.rb', line 25

def initialize
    @socket = UDPSocket.open
end

Instance Method Details

#closeObject



29
30
31
# File 'lib/snmp/manager.rb', line 29

def close
    @socket.close
end

#recv(max_bytes) ⇒ Object



37
38
39
# File 'lib/snmp/manager.rb', line 37

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

#send(data, host, port) ⇒ Object



33
34
35
# File 'lib/snmp/manager.rb', line 33

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