Created
July 6, 2011 04:18
-
-
Save meanphil/1066552 to your computer and use it in GitHub Desktop.
ZMQ Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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