Skip to content

Instantly share code, notes, and snippets.

@meanphil
Created July 6, 2011 04:18
Show Gist options
  • Save meanphil/1066552 to your computer and use it in GitHub Desktop.
Save meanphil/1066552 to your computer and use it in GitHub Desktop.
ZMQ Test
require 'rubygems'
require 'ffi-rzmq'
context = ZMQ::Context.new
submit = context.socket(ZMQ::REQ)
submit.connect("tcp://127.0.0.1:5454")
submit.send_string "some image: " + rand().to_s
require 'rubygems'
require 'ffi-rzmq'
context = ZMQ::Context.new
sock = context.socket(ZMQ::REP)
sock.bind("tcp://*:5454")
poller = ZMQ::Poller.new
poller.register(sock)
loop do
print "Polling..."
$stdout.flush
poller.poll(:blocking)
puts " Done"
poller.readables.each do |socket|
if socket === sock
message = sock.recv_string
puts "Got message: #{message}"
break
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment