Skip to content

Instantly share code, notes, and snippets.

@schmurfy
Created August 8, 2010 12:37
Show Gist options
  • Save schmurfy/513982 to your computer and use it in GitHub Desktop.
Save schmurfy/513982 to your computer and use it in GitHub Desktop.
# client
require 'zmq'
ctx = ZMQ::Context.new(1)
s = ctx.socket(ZMQ::REQ);
# max queue size
s.setsockopt(ZMQ::HWM, 100);
s.connect("tcp://127.0.0.1:7000");
msg = "msg_content"
while 1
puts "Sending..."
s.send(msg, 0)
puts "Receiving..."
p s.recv(0)
end
# server
require 'zmq'
ctx = ZMQ::Context.new(1)
s = ctx.socket(ZMQ::REP);
# max queue size
s.setsockopt(ZMQ::HWM, 100);
s.bind("tcp://127.0.0.1:7000");
while 1
puts "Receiving..."
msg = s.recv(0)
puts "Sending..."
s.send("#{$$} - #{msg}", 0)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment