Class: SNMP::UDPTransport
- Inherits:
-
Object
- Object
- SNMP::UDPTransport
- 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
- #close ⇒ Object
-
#initialize(address_family) ⇒ UDPTransport
constructor
A new instance of UDPTransport.
- #recv(max_bytes) ⇒ Object
- #send(data, host, port) ⇒ Object
Constructor Details
#initialize(address_family) ⇒ UDPTransport
Returns a new instance of UDPTransport.
41 42 43 |
# File 'lib/snmp/manager.rb', line 41 def initialize(address_family) @socket = UDPSocket.open(address_family) end |
Instance Method Details
#close ⇒ Object
45 46 47 |
# File 'lib/snmp/manager.rb', line 45 def close @socket.close end |
#recv(max_bytes) ⇒ Object
53 54 55 |
# File 'lib/snmp/manager.rb', line 53 def recv(max_bytes) @socket.recv(max_bytes) end |
#send(data, host, port) ⇒ Object
49 50 51 |
# File 'lib/snmp/manager.rb', line 49 def send(data, host, port) @socket.send(data, 0, host, port) end |