Hello everybody,

I'm stuck with a simple task I want to complete using druby.

I have a server and some  client processes. It is easy to make the client
execute code on the server side. But now I want to call back to the client
and execute a function there. But as soon as I pass a client object or
lambda function to the server, it blows up.

Here are my thoughts so far as a minimal example (I really tried to make
it short, so no $SAFE and friends):

== server.rb ==
require 'drb/drb'

class RemoteControl
  include DRb::DRbUndumped

  def initialize(client)
    @client = client
  end

  def callback
    @client.callback
  end
end

# The drb server
class Server
  def initialize(uri)
    @clients = []
    DRb.start_service(uri, self) # Start drb service
  end

  def connect(client)
    remote_control = RemoteControl.new(self, clientcallback) @clients <<
    remote_control
    remote_control
  end
end


TheServer = Server.new('druby://localhost:12345')

DRb.thread.join # Wait for the drb server thread to finish before exiting.
== eof ==

== client.rb ==
require 'drb/drb'

class RemoteControl
  include DRb::DRbUndumped

  def initialize(uri = 'druby://localhost:12345')
    @server = DRbObject.new_with_uri(uri) @remote = @server.connect(self)
  end

  def act
    @remote.callback
  end

  def callback
    puts "Called back"
  end
end

r = RemoteControl.new
r.act
r = nil
== eof ==

It blows up with:
/usr/lib/ruby/1.8/drb/drb.rb:1513:in `current_server':
DRb::DRbServerNotFound (DRb::DRbConnError)
        from /usr/lib/ruby/1.8/drb/drb.rb:1575:in `to_id' from
        /usr/lib/ruby/1.8/drb/drb.rb:981:in `initialize' from
        /usr/lib/ruby/1.8/drb/drb.rb:542:in `new' from
        /usr/lib/ruby/1.8/drb/drb.rb:542:in `dump' from
        /usr/lib/ruby/1.8/drb/drb.rb:581:in `send_request' from
        /usr/lib/ruby/1.8/drb/drb.rb:580:in `each' from
        /usr/lib/ruby/1.8/drb/drb.rb:580:in `send_request' from
        /usr/lib/ruby/1.8/drb/drb.rb:849:in `send_request' from
        /usr/lib/ruby/1.8/drb/drb.rb:1088:in `send_message' from
        /usr/lib/ruby/1.8/drb/drb.rb:1014:in `method_missing' from
        /usr/lib/ruby/1.8/drb/drb.rb:1013:in `open' from
        /usr/lib/ruby/1.8/drb/drb.rb:1013:in `method_missing' from
        ./drb.client.test.rb:11:in `initialize' from
        ./drb.client.test.rb:23:in `new' from ./drb.client.test.rb:23

which is not really helpful to me.

$ ruby -v
ruby 1.8.1 (2004-02-03) [i386-linux]

Thanks a lot for your help.

Brian

-- 
Brian Schröäer
http://www.brian-schroeder.de/