Professional Web Applications Themes

getaddrinfo :: ? - Ruby

I'm tinkering around with Borges on my XP box and one of the first things it tries to do out of the chute is: server = WEBrick::HTTPServer.new(options) server.listen('::', 7000) The listen method inside WEBrick is: def listen(address, port) res = Socket::getaddrinfo(address, port, Socket::AF_UNSPEC, # address family Socket::SOCK_STREAM, # socket type 0, # protocol Socket::AI_PASSIVE) # flag I assume '::' is shorthand for something, localhost if I had to guess ... but Googling for :: doesn't work so I've no idea where to start looking. This is raised as an error: c:/ruby/lib/ruby/1.8/webrick/server.rb:77:in `getaddrinfo': getaddrinfo: no addr ess associated with hostname. (SocketError) ...

  1. #1

    Default getaddrinfo :: ?

    I'm tinkering around with Borges on my XP box and one of the first
    things it tries to do out of the chute is:

    server = WEBrick::HTTPServer.new(options)
    server.listen('::', 7000)

    The listen method inside WEBrick is:

    def listen(address, port)
    res = Socket::getaddrinfo(address, port,
    Socket::AF_UNSPEC, # address family
    Socket::SOCK_STREAM, # socket type
    0, # protocol
    Socket::AI_PASSIVE) # flag

    I assume '::' is shorthand for something, localhost if I had to guess
    ... but Googling for :: doesn't work so I've no idea where to start
    looking. This is raised as an error:

    c:/ruby/lib/ruby/1.8/webrick/server.rb:77:in `getaddrinfo': getaddrinfo:
    no addr
    ess associated with hostname. (SocketError)
    from c:/ruby/lib/ruby/1.8/webrick/server.rb:77:in `listen'
    from C:/ruby/lib/ruby/site_ruby/1.8/Borges/WEBrick.rb:67:in `create'
    from C:/ruby/lib/ruby/site_ruby/1.8/Borges/WEBrick.rb:77:in `start'
    from C:/ruby/lib/ruby/site_ruby/1.8/Borges/WEBrick.rb:88

    Can anyone help me here?

    --
    Chris
    http://clabs.org/blogki




    Chris Guest

  2. #2

    Default Re: getaddrinfo :: ?

    Chris Morris wrote:
     

    I replaced the Borges/WEBrick.rb code with localhost and it gets past
    getaddrinfo, but then fails on the TCPServer.new line:

    def listen(address, port)
    res = Socket::getaddrinfo(address, port,
    Socket::AF_UNSPEC, # address family
    Socket::SOCK_STREAM, # socket type
    0, # protocol
    Socket::AI_PASSIVE) # flag
    last_error = nil
    sockets = []
    res.each{|ai|
    begin
    logger.debug("TCPServer.new(#{ai[3]}, #{ai[1]})")
    sock = TCPServer.new(ai[3], ai[1])
    Utils::set_close_on_exec(sock)
    sockets << sock
    rescue => ex
    logger.warn("TCPServer Error: #{ex}")
    last_error = ex
    end
    }
    raise last_error if sockets.empty?
    return sockets
    end

    with the following:

    c:/ruby/lib/ruby/1.8/webrick/server.rb:91:in `listen': Unknown Error -
    bind(2) (
    Errno::E048)
    from C:/ruby/lib/ruby/site_ruby/1.8/Borges/WEBrick.rb:67:in `create'
    from C:/ruby/lib/ruby/site_ruby/1.8/Borges/WEBrick.rb:77:in `start'
    from C:/ruby/lib/ruby/site_ruby/1.8/Borges/WEBrick.rb:88

    --
    Chris
    http://clabs.org/blogki




    Chris Guest

  3. #3

    Default Re: getaddrinfo :: ?

    Chris Morris wrote:
     

    I'm guessing this is older Borges code with newer WEBrick code. This is
    the failing Borges code:

    server = WEBrick::HTTPServer.new(options)
    server.listen('127.0.0.1', 7000)
    server.mount("/borges", self, options)

    The HTTPServer.new call itself sets up shop on TCP port 7000, so the
    following listen call is failing because the port is already in use.
    Remmed out the .listen line and now we're rolling.

    --
    Chris
    http://clabs.org/blogki





    Chris Guest

  4. #4

    Default Re: getaddrinfo :: ?

    --sMkrXc3LRVOjR
    Content-Type: text/plain; cht=us-ascii
    Content-Disposition: inline
    Content-Transfer-Encoding: quoted-printable

    Chris Morris (org) wrote:
     
    >=20
    > I'm guessing this is older Borges code with newer WEBrick code. This is=[/ref]
    =20 

    See alpha3, which does this the right way:
    http://segment7.net/ruby-code/borges/Borges-1.0.0-alpha3.tar.gz

    For reference, the correct way to set up a v4/v6 WEBrick server that
    works out of the box on v4-only hosts is this:

    def create(options)
    options[:BindAddress] ||=3D nil
    options[:Port] ||=3D 7000

    server =3D WEBrick::HTTPServer.new(options)

    return server
    end

    When the :BindAddress option is set to nil, getaddrinfo will
    return both :: and 0.0.0.0 on an IPv6 system, and the server will bind
    to both.

    :: is kinda but not really an IPv6 equivalent to 0.0.0.0 (there are
    several broadcast addresses for IPv6, depending upon who you want
    to talk to).

    --=20
    Eric Hodel - net - http://segment7.net
    All messages signed with fingerprint:
    FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04


    --sMkrXc3LRVOjR
    Content-Type: application/pgp-signature
    Content-Disposition: inline

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.2 (FreeBSD)

    iD8DBQE/6T+pMypVHHlsnwQRApdtAKCbTj3pkiRi7QngN4tyEqEoadZilA Cghcyz
    jWv18raH4hlAbAWr2FnVd9o=
    =OdQ5
    -----END PGP SIGNATURE-----

    --sMkrXc3LRVOjR--

    Eric Guest

  5. #5

    Default Re: getaddrinfo :: ?

    --EqVOK5mkaJAMmtSx
    Content-Type: text/plain; cht=us-ascii
    Content-Disposition: inline
    Content-Transfer-Encoding: quoted-printable

    Eric Hodel (net) wrote:
     

    Oh, ha! I lied, I fixed this _after_ alpha3 (about 5 minutes after) :(

    Here's the patch:

    CS file: /home/cvs/ruby/seaside2/Borges/lib/Borges/WEBrick.rb,v
    retrieving revision 1.9
    retrieving revision 1.10
    diff -u -p -F ^[ ]*\(class\|module\|def\) -r1.9 -r1.10
    --- ruby/seaside2/Borges/lib/Borges/WEBrick.rb 2003/12/21 02:53:52 1.9
    +++ ruby/seaside2/Borges/lib/Borges/WEBrick.rb 2003/12/22 04:05:49 1.10
    -60,11 +60,10 def do_GET(req, res)
    # and mounts the Borges::WEBrickServlet on /borges.
    =20
    def self.create(options)
    - options[:BindAddress] ||=3D '0.0.0.0'
    + options[:BindAddress] ||=3D nil
    options[:Port] ||=3D 7000
    =20
    server =3D WEBrick::HTTPServer.new(options)
    - server.listen('::', 7000)
    server.mount("/borges", self, options)
    =20
    return server


    --=20
    Eric Hodel - net - http://segment7.net
    All messages signed with fingerprint:
    FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04


    --EqVOK5mkaJAMmtSx
    Content-Type: application/pgp-signature
    Content-Disposition: inline

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.2 (FreeBSD)

    iD8DBQE/6UE1MypVHHlsnwQRAoTSAJwKUpJZL9AHcni8kB/y8SHs6rGbFwCdF+NC
    wIHMcSmEghF3a4aRQfeTT50=
    =ID7n
    -----END PGP SIGNATURE-----

    --EqVOK5mkaJAMmtSx--

    Eric Guest

Similar Threads

  1. call to getaddrinfo() using bind library
    By kishore in forum UNIX Programming
    Replies: 6
    Last Post: October 13th, 04:49 PM
  2. procedure entry point ,getaddrinfo not found in wscupdateprovider
    By okaakoush in forum ASP.NET Web Services
    Replies: 0
    Last Post: August 24th, 11:28 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139