On Sat, 27 Sep 2003 23:34:54 +0900, ts <decoux / moulon.inra.fr> wrote: >R> Since when did the lack of reverse mean that forward lookups were broken? > Why you don't quote completely the message. You find this normal ? > > svg% host cancer.org > cancer.org has address 0.0.0.0 > cancer.org has address 209.135.47.118 > svg% *sigh* No, that's not normal, but you then demonstrated that it had no reverse -- seemingly to make your point. My apologies if I misunderstood, but the fact remains that Ruby's gethostbyname *is* seriously broken and won't look up hostnames that have no reverse, "broken" or not. For example, rotten.com can't be looked up using Ruby and isn't "broken". > host rotten.com rotten.com has address 216.218.248.174 > host 216.218.248.174 Host not found. > irb irb(main):001:0> require 'socket' => true irb(main):002:0> Socket::gethostbyname('rotten.com') SocketError: host not found from (irb):2:in `gethostbyname' from (irb):2 We already know that the "broken" cancer.org doesn't work. irb(main):003:0> Socket::gethostbyname('cancer.org') SocketError: host not found from (irb):3:in `gethostbyname' from (irb):3 But getaddrinfo does work, though requires you to specify a service name. irb(main):007:0> Socket::getaddrinfo('rotten.com', 'http') => [["AF_INET", 80, "216.218.248.174", "216.218.248.174", 2, 2, 17], ["AF_INET", 80, "216.218.248.174", "216.218.248.174", 2, 1, 6]] Broken it might be, but Ruby is still able to look up cancer.org's A records with no trouble if you use getaddrinfo. irb(main):009:0> Socket::getaddrinfo('cancer.org', 'http') => [["AF_INET", 80, "0.0.0.0", "0.0.0.0", 2, 2, 17], ["AF_INET", 80, "209.135.47.118", "209.135.47.118", 2, 2, 17], ["AF_INET", 80, "209.135.47.118", "209.135.47.118", 2, 1, 6], ["AF_INET", 80, "0.0.0.0", "0.0.0.0", 2, 1, 6]] Lest you think it's not Ruby's fault, both work fine with Perl. > perl -e 'print join(".", unpack("C4", (gethostbyname("rotten.com"))[4]))' 216.218.248.174 perl -e 'print join(".", unpack("C4", (gethostbyname("cancer.org"))[4])),"\n"' 209.135.47.118 They also work fine in Python. >>> import socket >>> socket.gethostbyname("rotten.com") '216.218.248.174' >>> socket.gethostbyname("cancer.org") '209.135.47.118' Why does Ruby persist in this nonsense? People will expect gethostbyname to Just Work since it does everywhere else. I posted RCR#46 about this bug almost two years ago now and, it seems, people are still having problems with it. Maybe it's time to fix it finally? RCR#46 lives at http://www.rubygarden.org/article.php?sid=118