Skip to content

Instantly share code, notes, and snippets.

@sugamasao
Created May 10, 2010 16:34
Show Gist options
  • Save sugamasao/396242 to your computer and use it in GitHub Desktop.
Save sugamasao/396242 to your computer and use it in GitHub Desktop.
#client.rb
require 'drb/drb'
there = DRbObject.new_with_uri("druby://localhost:12345")
puts there.method1("hoge")
there method2() do |num|
puts "yield = #{num}"
end
#server.rb
require 'drb/drb'
class Server
def method1(str)
STDERR.puts "call method1"
return ">> #{str}"
end
def method2(str)
STDERR.puts "call method2"
10.times do |num|
yield "#{str}.#{num}"
end
end
end
DRb.start_service("druby://localhost:12345", Server.new)
puts "start service..."
sleep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment