Simple test codes are here:


class TestServer
  include DRb::DRbUndumped

  def initialize
    @obj = Array.new
  end

  def register(addr)
    @obj << addr
  end

  def sum
    s = 0
    @obj.each do |t|
      v = DRbObject.new_with_uri(t).get_value
      if v.nil?
        puts s.to_s + " & error"
      end
      s += v
    end
    return s
  end
end

class TestClient
  include DRb::DRbUndumped

  def initialize(addr, server, value)
    DRbObject.new_with_uri(server).register(addr)
    @value = value
  end
  def get_value
    @value
  end
end


uri = "druby://localhost:"
server_uri = uri + "40000"
server = DRb.start_service(server_uri, TestServer.new)

max_size = 300

(1..max_size).each do |t|
  client_uri = uri + (40000 + t).to_s
  DRb.start_service(client_uri, TestClient.new(client_uri, server_uri,
t))
end

sum = DRbObject.new_with_uri(server_uri).sum
puts sum


For max_size = 10, sum = 55
For max_size = 100, sum = 5050

...

but

For max_size = 300,
DRb::DRbConnError exception raised.

try to make another DRb server after that error in the same process....
#<Errno::EMFILE: Too many open files - socket(2)> raised.


How can I open more than 300 DRb connection?
(I need to make about 1,000 connections .... )

-- 
Posted via http://www.ruby-forum.com/.