DRb en top de SSH

SSH (master *)$ cat -n helloworldserver.rb 
     1  require 'drb'
     2  
     3  class HelloWorldServer
     4    def say_hello
     5      'Hello world!'
     6    end
     7  end
     8  
     9  File.open('DRbhw.proc', 'w') do |f|
    10    f.puts $$
    11  end
    12  
    13  address = "druby://localhost:61676"
    14  DRb.start_service(address, obj=HelloWorldServer.new)
    15  puts "Process #{$$}: Server running at #{address} serving #{obj}"
    16  DRb.thread.join

SSH (master *)$ cat -n helloworldclient.rb 
     1  require 'drb'
     2  
     3  DRb.start_service
     4  
     5  address = "druby://localhost:61675"
     6  server = DRbObject.new_with_uri(address)
     7  
     8  puts server.inspect
     9  puts server.say_hello

En el portátil conectamos al servidor:

ACL (master *)$ uname -a
Darwin MacBookdeCasiano.local 11.2.0 ...
ACL (master *)$ ssh -L61675:localhost:61676 -N pp2

En el servidor ejecutamos el servicio:

pp2@nereida:~/src/projects-ull-casiano/ruby/DRb/SSH$ uname -a
Linux nereida.deioc.ull.es ...
pp2@nereida:~/src/projects-ull-casiano/ruby/DRb/SSH$ ruby helloworldserver.rb 
Process 32086: Server running at druby://localhost:61676 serving #<HelloWorldServer:0x00000001ce04b8>

En el portatil ejecutamos el cliente:

SSH (master *)$ ruby helloworldclient.rb 
#<HelloWorldServer:0x00000001ce04b8>
Hello world!

Casiano Rodríguez León
Licencia de Creative Commons
Programación Distribuida y Mejora del Rendimiento
por Casiano Rodríguez León is licensed under a Creative Commons Reconocimiento 3.0 Unported License.

Permissions beyond the scope of this license may be available at http://campusvirtual.ull.es/ocw/course/view.php?id=44.
2012-06-19