Class: Multicast::Sender
- Inherits:
-
Object
- Object
- Multicast::Sender
- Defined in:
- lib/multicast/sender.rb
Instance Attribute Summary collapse
-
#group ⇒ Object
Returns the value of attribute group.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Sender
constructor
A new instance of Sender.
- #send(message) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Sender
Returns a new instance of Sender.
5 6 7 8 |
# File 'lib/multicast/sender.rb', line 5 def initialize(opts={}) @group = opts[:group] @port = opts[:port] end |
Instance Attribute Details
#group ⇒ Object
Returns the value of attribute group.
3 4 5 |
# File 'lib/multicast/sender.rb', line 3 def group @group end |
#port ⇒ Object
Returns the value of attribute port.
3 4 5 |
# File 'lib/multicast/sender.rb', line 3 def port @port end |
Instance Method Details
#send(message) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/multicast/sender.rb', line 10 def send() begin socket = UDPSocket.open socket.setsockopt(Socket::IPPROTO_IP, Socket::IP_TTL, [1].pack('i')) socket.send(, 0, @group, @port) ensure socket.close end end |