Skip to content

Instantly share code, notes, and snippets.

@bosoxbill
Created October 1, 2010 18:34
Show Gist options
  • Save bosoxbill/606643 to your computer and use it in GitHub Desktop.
Save bosoxbill/606643 to your computer and use it in GitHub Desktop.
# author: Bill Desmarais bill@witsaid.com
# this code is licenced under the MIT/X11 licence.
require 'rubygems'
require 'zmq'
context = ZMQ::Context.new(1)
puts "Starting Hello World server..."
# socket to listen for clients
socket = context.socket(ZMQ::REP)
socket.bind("tcp://*:5555")
while true do
# Wait for next request from client
request = socket.recv
puts "Recieved request. Data: #{request.inspect}"
# Do some 'work'
sleep 1
# Send reply back to client
socket.send("world")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment