* io.c (rb_open_file): encoding in mode string was ignored if perm is
[ruby-svn.git] / sample / drb / drbm.rb
blob74a15a4696ad34aa5e03db8d45e4714b936cef8c
1 =begin
2  multiple DRbServer
3         Copyright (c) 1999-2002 Masatoshi SEKI 
4 =end
6 =begin
7  How to play.
9  Terminal 1
10  | % ruby drbm.rb 
11  | druby://yourhost:7640 druby://yourhost:7641
13  Terminal 2
14  | % ruby drbmc.rb druby://yourhost:7640 druby://yourhost:7641
15  | [#<DRb::DRbObject .... @uri="druby://yourhost:7640">, "FOO"]
16  | [#<DRb::DRbObject .... @uri="druby://yourhost:7641">, "FOO"]
18 =end
20 require 'drb/drb'
22 class Hoge
23   include DRbUndumped
24   def initialize(s)
25     @str = s
26   end
27   
28   def to_s
29     @str
30   end
31 end
33 class Foo
34   def initialize(s='FOO')
35     @hoge = Hoge.new(s)
36   end
38   def hello
39     @hoge
40   end
41 end
43 class Bar < Foo
44   def initialize(foo)
45     @hoge = foo.hello
46   end
47 end
50 if __FILE__ == $0
51   foo = Foo.new
52   s1 = DRb::DRbServer.new('druby://:7640', foo)
53   s2 = DRb::DRbServer.new('druby://:7641', Bar.new(foo))
55   puts "#{s1.uri} #{s2.uri}"
57   s1.thread.join
58   s2.thread.join
59 end