Class: SNMP::UDPServerTransport
- Inherits:
-
Object
- Object
- SNMP::UDPServerTransport
- Defined in:
- lib/snmp/manager.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(host, port, address_family) ⇒ UDPServerTransport
constructor
A new instance of UDPServerTransport.
- #recvfrom(max_bytes) ⇒ Object
- #send(data, host, port) ⇒ Object
Constructor Details
#initialize(host, port, address_family) ⇒ UDPServerTransport
Returns a new instance of UDPServerTransport.
542 543 544 545 |
# File 'lib/snmp/manager.rb', line 542 def initialize(host, port, address_family) @socket = UDPSocket.open(address_family) @socket.bind(host, port) end |
Instance Method Details
#close ⇒ Object
547 548 549 |
# File 'lib/snmp/manager.rb', line 547 def close @socket.close end |
#recvfrom(max_bytes) ⇒ Object
555 556 557 558 559 |
# File 'lib/snmp/manager.rb', line 555 def recvfrom(max_bytes) data, host_info = @socket.recvfrom(max_bytes) _, host_port, _, host_ip = host_info return data, host_ip, host_port end |
#send(data, host, port) ⇒ Object
551 552 553 |
# File 'lib/snmp/manager.rb', line 551 def send(data, host, port) @socket.send(data, 0, host, port) end |