That's better. Closing the socket is always polite.
This commit is contained in:
parent
fc2f46f05a
commit
288198d8f6
@ -1,4 +1,4 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# vim:fileencoding=utf-8:expandtab
|
||||
|
||||
require 'zmq'
|
||||
|
||||
@ -8,16 +8,21 @@ def main
|
||||
puts "Connecting to hello world server…"
|
||||
requester = context.socket(ZMQ::REQ)
|
||||
requester.connect("tcp://localhost:5555")
|
||||
puts "requester is a #{requester.class.inspect}"
|
||||
|
||||
0.upto(9) do |request_nbr|
|
||||
puts "Sending request #{request_nbr}…"
|
||||
requester.send("Hello")
|
||||
|
||||
reply = requester.recv(6)
|
||||
if requester.send("Hello")
|
||||
puts "Sent request, now receiving reply"
|
||||
reply = requester.recv
|
||||
puts "Received reply #{request_nbr}: [#{reply}]"
|
||||
end
|
||||
end
|
||||
|
||||
puts "Outside of loop now. Closing socket..."
|
||||
requester.close
|
||||
end
|
||||
|
||||
|
||||
if $0 == __FILE__
|
||||
main
|
||||
|
Loading…
Reference in New Issue
Block a user