Class: SyslogSD::RubyUdpSender
- Inherits:
-
Object
- Object
- SyslogSD::RubyUdpSender
- Defined in:
- lib/syslog-sd/ruby_sender.rb
Overview
Plain Ruby UDP sender.
Instance Attribute Summary collapse
-
#addresses ⇒ Object
Returns the value of attribute addresses.
Instance Method Summary collapse
-
#initialize(addresses) ⇒ RubyUdpSender
constructor
A new instance of RubyUdpSender.
- #send_datagram(datagram) ⇒ Object
Constructor Details
#initialize(addresses) ⇒ RubyUdpSender
Returns a new instance of RubyUdpSender.
6 7 8 9 10 |
# File 'lib/syslog-sd/ruby_sender.rb', line 6 def initialize(addresses) @addresses = addresses @i = 0 @socket = UDPSocket.open end |
Instance Attribute Details
#addresses ⇒ Object
Returns the value of attribute addresses.
4 5 6 |
# File 'lib/syslog-sd/ruby_sender.rb', line 4 def addresses @addresses end |
Instance Method Details
#send_datagram(datagram) ⇒ Object
12 13 14 15 16 |
# File 'lib/syslog-sd/ruby_sender.rb', line 12 def send_datagram(datagram) host, port = @addresses[@i] @i = (@i + 1) % @addresses.length @socket.send(datagram, 0, host, port) end |