[Bug:trunk] Socket.getaddrinfo("www.ruby-lang.org", 80) returns only UDP information


#1

1.9 e$B$He(B 1.8 e$B$Ge(B Socket.getaddrinfo(“www.ruby-lang.org”, 80)
e$B$NJV$jCM$,0c$$$^$9!#e(B

e$B0J2<$N$h$&$K!"e(B1.9 e$B$G$Oe(B 1e$BMWAG$NG[Ns$,JV$j!"e(B1.8
e$B$G$Oe(B 2e$BMWAG$NG[Ns$,JV$j$^$9!#e(B

% ./ruby -rpp -rsocket -ve ‘pp Socket.getaddrinfo(“www.ruby-lang.org”,
80)’
ruby 1.9.1 (2009-01-01 patchlevel-5000 trunk 21253) [i686-linux]
[[“AF_INET”, 80, “carbon.ruby-lang.org”, “221.186.184.68”, 2, 2, 17]]

% ruby-1.8 -rpp -rsocket -ve ‘pp Socket.getaddrinfo(“www.ruby-lang.org”,
80)’
ruby 1.8.7 (2008-12-26 revision 21066) [i686-linux]
[[“AF_INET”, 80, “carbon.ruby-lang.org”, “221.186.184.68”, 2, 1, 6],
[“AF_INET”, 80, “carbon.ruby-lang.org”, “221.186.184.68”, 2, 2, 17]]

1.8 e$B$NJV$jCM$Ne(B 2e$BMWAG$O$h$/;w$F$$$^$9$,!"e(B
e$B!VBhe(B5e$BMWAGe(B - e$B%=%1%C%H%?%$%W$KBP1~$9$ke(BIntegere$B!W$He(B
e$B!VBhe(B6e$BMWAGe(B -
e$B%W%m%H%3%k$KBP1~$9$ke(BIntegere$B!W$,0[$J$C$F$$$^$9!#e(B

e$B$3$l$,$J$K$+$H$$$&$H!"e(B1, 6 e$B$Oe(B TCP e$B$r0UL#$7$F$$$F!"e(B2,
17 e$B$Oe(B
UDP e$B$r0UL#$7$F$$$^$9!#e(B

% ./ruby -rsocket -e ’
p [Socket::SOCK_STREAM, Socket::IPPROTO_TCP]
p [Socket::SOCK_DGRAM, Socket::IPPROTO_UDP]’
[1, 6]
[2, 17]

1.9 e$B$G$O!“e(B2, 17 e$B$NMWAG$7$+$J$/$F!”$3$l$O$D$^$je(B UDP
e$B$N>pJs$7e(B
e$B$+JV$C$F$-$F$$$J$$$H$$$&$3$H$r0UL#$7$^$9!#e(B

www.ruby-lang.org:80 e$B$N>pJs$rMW5a$7$Fe(B TCP e$B$,=P$F$3$J$$$N$O$he(B
e$B$m$7$/$J$$$s$8$c$J$$$G$7$g$&$+!#e(B

e$BD4$Y$F$_$k$H!"e(Br20387 e$B$Ne(B

Fri Nov 28 18:31:21 2008 Yukihiro M. removed_email_address@domain.invalid

    * ext/socket/socket.c (sock_s_getaddrinfo): refactored to remove
      code duplication regarding getaddrinfo.

e$B$H$$$&JQ99$,860x$J$h$&$J$N$G$9$,!“5sF0$,JQ$o$C$F$7$^$C$F$$$ke(B
e$B$N$G!”%j%U%!%/%?%j%s%0$H$7$F$O<:GT$G$O$J$$$G$7$g$&$+!#e(B


#2

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:37674] [Bug:trunk]
Socket.getaddrinfo(“www.ruby-lang.org”, 80) returns only UDP
information”
on Fri, 2 Jan 2009 00:44:13 +0900, Tanaka A. removed_email_address@domain.invalid
writes:

|1.9 e$B$He(B 1.8 e$B$Ge(B Socket.getaddrinfo(“www.ruby-lang.org”, 80) e$B$NJV$jCM$,0c$$$^$9!#e(B
|e$B0J2<$N$h$&$K!"e(B1.9 e$B$G$Oe(B 1e$BMWAG$NG[Ns$,JV$j!"e(B1.8 e$B$G$Oe(B 2e$BMWAG$NG[Ns$,JV$j$^$9!#e(B

|www.ruby-lang.org:80 e$B$N>pJs$rMW5a$7$Fe(B TCP e$B$,=P$F$3$J$$$N$O$he(B
|e$B$m$7$/$J$$$s$8$c$J$$$G$7$g$&$+!#e(B
|
|e$BD4$Y$F$_$k$H!"e(Br20387 e$B$Ne(B
|
|Fri Nov 28 18:31:21 2008 Yukihiro M. removed_email_address@domain.invalid
|
| * ext/socket/socket.c (sock_s_getaddrinfo): refactored to remove
| code duplication regarding getaddrinfo.
|
|e$B$H$$$&JQ99$,860x$J$h$&$J$N$G$9$,!“5sF0$,JQ$o$C$F$7$^$C$F$$$ke(B
|e$B$N$G!”%j%U%!%/%?%j%s%0$H$7$F$O<:GT$G$O$J$$$G$7$g$&$+!#e(B

e$B$*$C$7$c$kDL$j$@$H;W$$$^$9!#$,!"@hDx;d$N<j85$G3NG’$7$?$H$3$me(B
Ruby 1.8e$B$He(B1.9e$B$GF1$87k2L$K$J$j$^$7$?e(B

[[“AF_INET”, 80, “carbon.ruby-lang.org”, “221.186.184.68”, 2, 1, 6],
[“AF_INET”, 80, “carbon.ruby-lang.org”, “221.186.184.68”, 2, 2, 17],
[“AF_INET”, 80, “carbon.ruby-lang.org”, “221.186.184.68”, 2, 3, 0]]

e$B<B9T$7$?$N$Oe(B

ruby 1.9.1 (2009-01-06 patchlevel-5000 trunk 21348) [i686-linux]

e$B$G$9$,!"$3$l$Oe(B

  • e$B4D6-$K$h$C$F0[$J$ke(B
  • e$BC/$+$,D>$7$F$/$@$5$C$?e(B

e$B$N$$$:$l$+$G$7$g$&$+!#:G6ae(Bsocket.ce$B$K<j$rF~$l$F$$$?$@$$$F$$$ke(B
e$B$N$OEDCf$5$s$J$N$G$_$:$+$iD>$7$F$/$@$5$C$?$N$G$7$g$&$+!#;d$He(B
e$BEDCf$5$s$G$O:#2s$OF1$8e(Bi686-linuxe$B$G$9$+$i!“4D6-0MB8$N2DG=@-$Oe(B
e$BDc$$$N$G$9$,!”%i%$%V%i%j$=$NB>$N%P!<%8%g%s$N0c$$$J$I$b$"$k$+e(B
e$B$b$7$l$^$;$s!#e(B

                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)

#3

e$B%A%1%C%He(B #987 e$B$,99?7$5$l$^$7$?!#e(B (by Yukihiro M.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B

fixed in r21278.

http://redmine.ruby-lang.org/issues/show/987


#4

In article removed_email_address@domain.invalid,
Yukihiro M. removed_email_address@domain.invalid writes:

  • e$B4D6-$K$h$C$F0[$J$ke(B
  • e$BC/$+$,D>$7$F$/$@$5$C$?e(B

e$B$N$$$:$l$+$G$7$g$&$+!#:G6ae(Bsocket.ce$B$K<j$rF~$l$F$$$?$@$$$F$$$ke(B
e$B$N$OEDCf$5$s$J$N$G$_$:$+$iD>$7$F$/$@$5$C$?$N$G$7$g$&$+!#;d$He(B

e$B$O$$!"e(Br21278 e$B$GD>$7$^$7$?!#e(B

r21278 | akr | 2009-01-02 23:36:39 +0900 (Fri, 02 Jan 2009) | 7 lines

  • ext/socket/socket.c: don’t apply socktype hack [ruby-core:184] for
    sock_s_getaddrinfo.
    (sock_getaddrinfo): add socktype_hack argument.
    (sock_addrinfo): call sock_getaddrinfo with socktype_hack.
    (sock_s_getaddrinfo): call sock_getaddrinfo without socktype_hack.
    [ruby-dev:37674]

e$B$H$$$&e(B log e$B$G$b?($l$F$"$j$^$9$,e(B [ruby-core:184]
e$B$N:Y9)$N1F6Ae(B
e$BHO0O$re(B Socket.getaddrinfo e$B$K$^$G9-$2$F$7$^$C$?$N$,<:GT$H$$$&e(B
e$B$3$H$G$9$+$M!#e(B

e$B$3$N:Y9)$Oe(B port e$B$,@0?t$@$C$?$ie(B socktype e$B$,L5;XDj$@$He(B
(e$B4D6-$Ke(B
e$B$h$C$Fe(B) Socket.sockaddr_in e$B$G%(%i!<$K$J$k$N$re(B SOCK_DGRAM
e$B$re(B
e$B;XDj$7$FKI$0$H$$$&$b$N$G!"e(B
e$B%(%i!<$K$J$k$N$Oe(B

% grep 514 /etc/services
shell 514/tcp
syslog 514/udp

e$B$_$?$$$J$"$$$^$$$J%1!<%9$,$"$k$H$$$&$b$C$H$b$JM}M3$,$"$j!"e(B
e$B%(%i!<$rKI$0$N$b!“e(BSocket.sockaddr_in e$B$Ge(B port
e$B$,$9$G$K@0?t$@$Ce(B
e$B$?$i$1$C$-$g$/LdBj$K$O$J$i$J$$$H$$$&$b$C$H$b$JM}M3$,$”$k$N$Ge(B
e$B$9$,!"e(B
Socket.getaddrinfo e$B$r8F$S=P$7$?;~$K$OM>7W$J8f@$OC$H$$$&$o$1e(B
e$B$G$9!#e(B