Skip to content

Instantly share code, notes, and snippets.

@boosty
Last active August 29, 2015 14:08
Show Gist options
  • Save boosty/80923cb86f0fa1864a5f to your computer and use it in GitHub Desktop.
Save boosty/80923cb86f0fa1864a5f to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'bundler/setup'
require 'ffi-rzmq'
context = ZMQ::Context.new
puts "Starting Listener..."
listener = context.socket(ZMQ::SUB)
listener.setsockopt(ZMQ::SUBSCRIBE, '')
range = (2..254)
puts "Connecting to 192.168.43.<#{range.inspect}>..."
range.each do |i|
listener.connect("tcp://192.168.43.#{i}:7315")
end
Thread.new do
loop do
msg = ""
listener.recv_string(msg)
puts msg if msg != ""
end
end
puts "Starting UI..."
ui = context.socket(ZMQ::PUB)
ui.bind("tcp://192.168.43.186:7315")
loop do
ui.send_string("<boosty> #{gets}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment