Class: Sloth::Snmp::UDPTransportExt

Inherits:
SNMP::UDPTransport
  • Object
show all
Defined in:
lib/sloth/snmp/impl.rb

Instance Method Summary collapse

Constructor Details

#initialize(address_family, bindto: nil, device: nil) ⇒ UDPTransportExt

Returns a new instance of UDPTransportExt.



9
10
11
12
13
14
15
16
17
18
# File 'lib/sloth/snmp/impl.rb', line 9

def initialize( address_family, bindto: nil, device: nil )
  super  address_family
  if  bindto
    host, port  =  bindto.split(':')    rescue nil
    @socket.bind( host, port.to_i )
  end
  if  device
    @socket.setsockopt( Socket::SOL_SOCKET, Socket::SO_BINDTODEVICE, device )
  end
end