Greetings,
Can anyone explain to me why this very simple little DRb client server pair
generates a DRb::DRbConnError when the client terminates? I’ve checked out
the books and the samples and I can’t see what I’m missing. I’m running
Ruby 1.8.1 on Win2000 and WinXP. The problem reproduces w/the pair running
on the same machine or (with the host id modified) when each is running on
separate machines.
Instructions: Run drbsvr.rb first, then run the drbclnt.rb. The output I
get from ruby follows below.
PS. I am unable to rescue the error that was raised by DRb, which BTW
puzzles me further.
Thanks for any help you can lend.
Ken.
···
drb server
require ‘drb’
class MySvr
def svc
puts "MySvr::svc called."
return "Service completed."
end
end
$stdout.sync=true;
while true
begin
puts "Starting MySvr…"
DRb.start_service(“druby://localhost:9000”, MySvr.new());
DRb.thread.join;
DRb.stop_service;
rescue DRb::DRbConnError
puts "Rescued DRbConnectionClosed: #{$!}"
end
end
drb client
require ‘drb’
DRb.start_service(nil,nil);
svr = DRbObject.new(nil, “druby://localhost:9000”)
10.times do
puts svr.svc();
end
DRb.stop_service;
Output:(rdb:1) c
Starting MySvr…
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
MySvr::svc called.
e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:104: connection closed' (DRb::D RbConnError) from e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:596:in
start’
from e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:596:in run' from e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:549:in
initialize’
from e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:737:in `new'
from e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:737:in
`start_servi
ce’
from H:/qbbpo/src/vendornet/etc/drbsvr.rb:17
e:/tools/ruby/lib/ruby/site_ruby/1.8/drb/drb.rb:104:
raise(DRbConnError, ‘c
onnection closed’) if sz.nil?
(rdb:3)