Why errors appear at Ruby?












-1















Objective
Add (uri, url) with port.



 # Help for carlos-romero   
# https://stackoverflow.com

# Help for 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 show this errors




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




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










share|improve this question





























    -1















    Objective
    Add (uri, url) with port.



     # Help for carlos-romero   
    # https://stackoverflow.com

    # Help for 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 show this errors




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




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










    share|improve this question



























      -1












      -1








      -1








      Objective
      Add (uri, url) with port.



       # Help for carlos-romero   
      # https://stackoverflow.com

      # Help for 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 show this errors




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




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










      share|improve this question
















      Objective
      Add (uri, url) with port.



       # Help for carlos-romero   
      # https://stackoverflow.com

      # Help for 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 show this errors




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




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







      ruby sockets url uri protocols






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 '18 at 13:47







      Eduardo Paulo Migo

















      asked Nov 21 '18 at 20:25









      Eduardo Paulo MigoEduardo Paulo Migo

      11




      11
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I see a few problems there. In your method fileProtocol it seems like you are setting the value of uri with an inline if (do X if condition), so that end immediately following the if is unnecessary. Also, the = should be ==



          I believe you want something like this:



          def fileProtocol( url , server ) 
          uri = URI(url, server) if scheme == uri.scheme
          [url, server]
          end

          puts fileProtocol(url, server)


          EDIT: Also, as @muistooshort pointed in the comments, the return value of the method (its last line) should wrap any multiple values you want to return in an array.






          share|improve this answer


























          • Thanks! I'll see if it works!

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:52











          • syntax error, unexpected 'n', expecting '=' url, server

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:57











          • syntax error, unexpected end-of-input, expecting keyword_end puts fileProtocol(url)

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:57











          • these errors appeared

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:58






          • 1





            I think you want [url, server] at the end of the method, Ruby doesn't really let you return multiple values, you explicitly return an array and then deconstruct it during the assignment.

            – mu is too short
            Nov 21 '18 at 21:11











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419978%2fwhy-errors-appear-at-ruby%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I see a few problems there. In your method fileProtocol it seems like you are setting the value of uri with an inline if (do X if condition), so that end immediately following the if is unnecessary. Also, the = should be ==



          I believe you want something like this:



          def fileProtocol( url , server ) 
          uri = URI(url, server) if scheme == uri.scheme
          [url, server]
          end

          puts fileProtocol(url, server)


          EDIT: Also, as @muistooshort pointed in the comments, the return value of the method (its last line) should wrap any multiple values you want to return in an array.






          share|improve this answer


























          • Thanks! I'll see if it works!

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:52











          • syntax error, unexpected 'n', expecting '=' url, server

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:57











          • syntax error, unexpected end-of-input, expecting keyword_end puts fileProtocol(url)

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:57











          • these errors appeared

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:58






          • 1





            I think you want [url, server] at the end of the method, Ruby doesn't really let you return multiple values, you explicitly return an array and then deconstruct it during the assignment.

            – mu is too short
            Nov 21 '18 at 21:11
















          0














          I see a few problems there. In your method fileProtocol it seems like you are setting the value of uri with an inline if (do X if condition), so that end immediately following the if is unnecessary. Also, the = should be ==



          I believe you want something like this:



          def fileProtocol( url , server ) 
          uri = URI(url, server) if scheme == uri.scheme
          [url, server]
          end

          puts fileProtocol(url, server)


          EDIT: Also, as @muistooshort pointed in the comments, the return value of the method (its last line) should wrap any multiple values you want to return in an array.






          share|improve this answer


























          • Thanks! I'll see if it works!

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:52











          • syntax error, unexpected 'n', expecting '=' url, server

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:57











          • syntax error, unexpected end-of-input, expecting keyword_end puts fileProtocol(url)

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:57











          • these errors appeared

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:58






          • 1





            I think you want [url, server] at the end of the method, Ruby doesn't really let you return multiple values, you explicitly return an array and then deconstruct it during the assignment.

            – mu is too short
            Nov 21 '18 at 21:11














          0












          0








          0







          I see a few problems there. In your method fileProtocol it seems like you are setting the value of uri with an inline if (do X if condition), so that end immediately following the if is unnecessary. Also, the = should be ==



          I believe you want something like this:



          def fileProtocol( url , server ) 
          uri = URI(url, server) if scheme == uri.scheme
          [url, server]
          end

          puts fileProtocol(url, server)


          EDIT: Also, as @muistooshort pointed in the comments, the return value of the method (its last line) should wrap any multiple values you want to return in an array.






          share|improve this answer















          I see a few problems there. In your method fileProtocol it seems like you are setting the value of uri with an inline if (do X if condition), so that end immediately following the if is unnecessary. Also, the = should be ==



          I believe you want something like this:



          def fileProtocol( url , server ) 
          uri = URI(url, server) if scheme == uri.scheme
          [url, server]
          end

          puts fileProtocol(url, server)


          EDIT: Also, as @muistooshort pointed in the comments, the return value of the method (its last line) should wrap any multiple values you want to return in an array.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 22 '18 at 11:40

























          answered Nov 21 '18 at 20:48









          Carlos RomeroCarlos Romero

          237215




          237215













          • Thanks! I'll see if it works!

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:52











          • syntax error, unexpected 'n', expecting '=' url, server

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:57











          • syntax error, unexpected end-of-input, expecting keyword_end puts fileProtocol(url)

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:57











          • these errors appeared

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:58






          • 1





            I think you want [url, server] at the end of the method, Ruby doesn't really let you return multiple values, you explicitly return an array and then deconstruct it during the assignment.

            – mu is too short
            Nov 21 '18 at 21:11



















          • Thanks! I'll see if it works!

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:52











          • syntax error, unexpected 'n', expecting '=' url, server

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:57











          • syntax error, unexpected end-of-input, expecting keyword_end puts fileProtocol(url)

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:57











          • these errors appeared

            – Eduardo Paulo Migo
            Nov 21 '18 at 20:58






          • 1





            I think you want [url, server] at the end of the method, Ruby doesn't really let you return multiple values, you explicitly return an array and then deconstruct it during the assignment.

            – mu is too short
            Nov 21 '18 at 21:11

















          Thanks! I'll see if it works!

          – Eduardo Paulo Migo
          Nov 21 '18 at 20:52





          Thanks! I'll see if it works!

          – Eduardo Paulo Migo
          Nov 21 '18 at 20:52













          syntax error, unexpected 'n', expecting '=' url, server

          – Eduardo Paulo Migo
          Nov 21 '18 at 20:57





          syntax error, unexpected 'n', expecting '=' url, server

          – Eduardo Paulo Migo
          Nov 21 '18 at 20:57













          syntax error, unexpected end-of-input, expecting keyword_end puts fileProtocol(url)

          – Eduardo Paulo Migo
          Nov 21 '18 at 20:57





          syntax error, unexpected end-of-input, expecting keyword_end puts fileProtocol(url)

          – Eduardo Paulo Migo
          Nov 21 '18 at 20:57













          these errors appeared

          – Eduardo Paulo Migo
          Nov 21 '18 at 20:58





          these errors appeared

          – Eduardo Paulo Migo
          Nov 21 '18 at 20:58




          1




          1





          I think you want [url, server] at the end of the method, Ruby doesn't really let you return multiple values, you explicitly return an array and then deconstruct it during the assignment.

          – mu is too short
          Nov 21 '18 at 21:11





          I think you want [url, server] at the end of the method, Ruby doesn't really let you return multiple values, you explicitly return an array and then deconstruct it during the assignment.

          – mu is too short
          Nov 21 '18 at 21:11




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419978%2fwhy-errors-appear-at-ruby%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          If I really need a card on my start hand, how many mulligans make sense? [duplicate]

          Alcedinidae

          Can an atomic nucleus contain both particles and antiparticles? [duplicate]