Mistakes in Ruby come because?

Asked

Viewed 52 times

0

Goal Add (Uri, url) with port.

 # Ajuda por carlos-romero   
 # https://stackoverflow.com

 # Ajuda por mu-is-too-short
 # https://stackoverflow.com

require 'uri'
require 'socket'

url = 'file://C://'

 class Class1
    def fileProtocol( url )
        uri = URI(url) if scheme = uri.scheme
      puts fileProtocol(url)
    end
  end

 class Class2
     def fileProtocolPort( server )
         server = TCPServer.open(8080)
           for i in  0..5
           client = server.accept
             client.puts(Time.now.ctime)
            client.puts "Closing the connection. Bye!"
            client.close
            end
            end
            end

ruby shows these errors

Traceback (Most recent call last): 2: from main.Rb:7:in <main>' 1: from main.rb:7:inopen' main.Rb:7:in `initialize': Address already in use - bind(2) for nil port 8080 (Errno::EADDRINUSE)

So, what does this mean? Can you help me?

  • What is that if inside the function? Why does it have two "end"?

  • This if is Scheme 'url schema' ... If 'If' is Scheme 'url schema' equal to Uri.Scheme ... Well Uri = URI(url, server) that’s it.

  • The 2 end’s were to terminate within the def ( url, server )

  • managed to resolve that issue?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.