Hello!

> Is it possible to tell DRb to use a single socket connection? 
> Could it use UDP as an option?

I have a plan to release drb-1.4 or 1.5, in the future. 
It use a single socket connection or UDP connecton.

 dRuby Devel page (Japanese, sorry)
 -> http://www.jin.gr.jp/~nahi/RWiki/?cmd=view;name=dRuby%B3%AB%C8%AF%C8%C7

 CVS repository
 -> http://www.ruby-lang.org/~knu/cgi-bin/cvsweb.cgi/lib/drb/


> * test3 calls a remote object, which has been created by another remote
> object. test3 sometimes (rarely) gives the "recycled object" error message
> on the client side.

| def test3 (remote)
|   child = remote.createChild
|   c = CallbackTarget.new
|   10000.times do |x|
|     puts "Iteration #{x}"
|     child.callback_method c
|   end
| end

because, the remote.createChild was GCed. Try it.

dRuby provide basic of distributed object environment,
not provde distributed GC system. It's application domain.


----- server.rb
# add ServerObject#gc method

class ServerObject
  include DRbUndumped
  def simple_method
    puts "A simple method"
  end
  def callback_method (object)
    # try to call back an object on the remote (client) side
    puts "I call back object #{object.id} and get: '#{object.callback}'"
  end
  def createChild
    ServerChild.new
  end
  def gc
    GC.start
  end
end

---- client.rb

def test3 (remote)
  child = remote.createChild
  c = CallbackTarget.new
  remote.gc                  # GC now!
  10000.times do |x|
    puts "Iteration #{x}"
    child.callback_method c
  end
end



Don't mind, You can solve this problem.

== plan 1. TimerIdConv

---- server.rb
require 'thread'
require 'drb/drb'
require 'drb/timeridconv'

....

if __FILE__ == $0
  here = ARGV.shift
  x = ServerObject.new
  DRb.install_id_conv(TimerIdConv.new)	# customize id<->obj converter.
  DRb.start_service(here, x)
  puts "Server URI is #{DRb.uri}"
  DRb.thread.join
end





== plan 2. iterator

---- server.rb

require 'thread'
require 'drb/drb'

....

# add openChild method

class ServerObject
  include DRbUndumped
  def simple_method
    puts "A simple method"
  end
  def callback_method (object)
    # try to call back an object on the remote (client) side
    puts "I call back object #{object.id} and get: '#{object.callback}'"
  end
  def createChild
    ServerChild.new
  end
  def openChild
    yield(ServerChild.new)
  end
  def gc
    GC.start
  end
end

--- client.rb

def test4 (remote)
  c = CallbackTarget.new
  remote.openChild do |child|
    remote.gc
    10000.times do |x|
      puts "Iteration #{x}"
      child.callback_method c
    end
  end
end