For fun, try running client before the server.
Created
February 7, 2012 03:23
-
-
Save jqr/1756938 to your computer and use it in GitHub Desktop.
ZeroMQ push/pull example
This file contains hidden or 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 'zmq' | |
# reference http://zguide.zeromq.org/rb:taskwork | |
context = ZMQ::Context.new | |
pull = context.socket(ZMQ::PULL) | |
pull.connect 'tcp://127.0.0.1:5555' | |
while line = pull.recv | |
puts line | |
end |
This file contains hidden or 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 'zmq' | |
# reference http://zguide.zeromq.org/rb:taskvent | |
context = ZMQ::Context.new | |
push = context.socket ZMQ::PUSH | |
push.bind 'tcp://*:5555' | |
i = 0 | |
loop do | |
push.send "example message #{i+=1}" | |
sleep 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment