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(host, port) ⇒ UDPTransport
constructor
A new instance of UDPTransport.
- #recv(max_bytes) ⇒ Object
- #send(data) ⇒ Object
Constructor Details
#initialize(host, port) ⇒ UDPTransport
Returns a new instance of UDPTransport.
25 26 27 28 |
# File 'lib/snmp/manager.rb', line 25 def initialize(host, port) @socket = UDPSocket.open @socket.connect(host, port) end |
Instance Method Details
#close ⇒ Object
30 31 32 |
# File 'lib/snmp/manager.rb', line 30 def close @socket.close end |
#recv(max_bytes) ⇒ Object
38 39 40 |
# File 'lib/snmp/manager.rb', line 38 def recv(max_bytes) @socket.recv(max_bytes) end |
#send(data) ⇒ Object
34 35 36 |
# File 'lib/snmp/manager.rb', line 34 def send(data) @socket.send(data, 0) end |