Created
July 29, 2010 15:34
-
-
Save hryk/498436 to your computer and use it in GitHub Desktop.
zmq test.
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
#!/usr/bin/env ruby | |
# | |
require 'rubygems' | |
require 'zmq' | |
ctx = ZMQ::Context.new() | |
sock = ctx.socket(ZMQ::REQ) | |
sock.connect("tcp://127.0.0.1:5000") | |
sock.connect("tcp://127.0.0.1:5500") | |
sock.connect("tcp://127.0.0.1:6000") | |
(0..10).each do |i| | |
msg = "hello #{i}" | |
sock.send(msg) | |
puts "Sent #{msg}" | |
msg_in = sock.recv() | |
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'zmq' | |
host = '127.0.0.1'; | |
port = ARGV[0]; | |
puts '-------------------------------------------' | |
puts "ZMQ version : #{ZMQ.version}" | |
puts "server start at tcp://#{host}:#{port}" | |
# Create context | |
ctx = ZMQ::Context.new(); | |
sock = ctx.socket(ZMQ::REP) | |
addr = "tcp://#{host}:#{port}" | |
sock.bind(addr) | |
loop do | |
msg = sock.recv() | |
puts "Got #{msg}" | |
sock.send(msg) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment