user3624394
user3624394

Reputation: 21

Error in druby when reading files

I'm using dRuby and i'm trying to read a file in this way:

SERVER'S CODE:

require 'drb/drb'
URI="druby://0.0.0.0:8787"
class TimeServer
      def leer(nombre)
          puts nombre
          lines = []
          File.open(nombre, "r") do |file|
              file.each_line do |line|
                lines << line
              end
          end
          return lines
       end
end
FRONT_OBJECT=TimeServer.new
$SAFE = 1 
DRb.start_service(URI, FRONT_OBJECT)
DRb.thread.join

CLIENT'S CODE:

SERVER_URI="druby://192.168.56.1:8787"
DRb.start_service
timeserver = DRbObject.new_with_uri(SERVER_URI)
puts timeserver.leer("aname")

This is the error on the client's console:

    C:/Ruby193/lib/ruby/1.9.1/drb/drb.rb:570:in `load': connection closed (DRb::DRbConnError)
    from C:/Ruby193/lib/ruby/1.9.1/drb/drb.rb:632:in `recv_reply'
    from C:/Ruby193/lib/ruby/1.9.1/drb/drb.rb:918:in `recv_reply'
    from C:/Ruby193/lib/ruby/1.9.1/drb/drb.rb:1197:in `send_message'
    from C:/Ruby193/lib/ruby/1.9.1/drb/drb.rb:1088:in `block (2 levels) in method_missing'
    from C:/Ruby193/lib/ruby/1.9.1/drb/drb.rb:1172:in `open'
    from C:/Ruby193/lib/ruby/1.9.1/drb/drb.rb:1087:in `block in method_missing'
    from C:/Ruby193/lib/ruby/1.9.1/drb/drb.rb:1105:in `with_friend'
    from C:/Ruby193/lib/ruby/1.9.1/drb/drb.rb:1086:in `method_missing'
    from C:/Users/federico/Downloads/RUBY/PROGRAMITAS/pruebaclien.rb:5:in `<main>'

The program prints in the server's console the value of "nombre", but it crashes when it gets to File.open(nombre, "r").

Upvotes: 1

Views: 89

Answers (0)

Related Questions