Class: OSC::BroadcastClient
- Inherits:
-
Object
- Object
- OSC::BroadcastClient
- Defined in:
- lib/osc-ruby/broadcast_client.rb
Constant Summary collapse
- BROADCAST_ADDRESS =
'<broadcast>'
Instance Attribute Summary collapse
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(port, local_ip = nil) ⇒ BroadcastClient
constructor
A new instance of BroadcastClient.
- #send(mesg) ⇒ Object
Constructor Details
#initialize(port, local_ip = nil) ⇒ BroadcastClient
Returns a new instance of BroadcastClient.
10 11 12 13 14 15 16 17 18 |
# File 'lib/osc-ruby/broadcast_client.rb', line 10 def initialize(port, local_ip = nil) @port = port @so = UDPSocket.new @so.setsockopt Socket::SOL_SOCKET, Socket::SO_BROADCAST, true if local_ip @so.setsockopt Socket::IPPROTO_IP, Socket::IP_MULTICAST_IF, IPAddr.new(local_ip).hton @so.bind(local_ip, 0) end end |
Instance Attribute Details
#port ⇒ Object (readonly)
Returns the value of attribute port.
8 9 10 |
# File 'lib/osc-ruby/broadcast_client.rb', line 8 def port @port end |
Instance Method Details
#send(mesg) ⇒ Object
20 21 22 |
# File 'lib/osc-ruby/broadcast_client.rb', line 20 def send(mesg) @so.send(mesg.encode, 0, BROADCAST_ADDRESS, @port) end |