Socket.unpack_sockaddr_in(Socket.sockaddr_un("/tmp/s")) is [


#1

e$B$U$H!"e(Bsockaddr_in e$B$re(B unpack_sockaddr_un e$B$7$?$j!"e(B
sockaddr_un e$B$re(B unpack_sockaddr_in e$B$7$?$j$7$F$b%(%i!<$K$J$i$:e(B
e$B$K$J$s$+CM$,JV$C$F$/$k$3$H$K5$$,$D$-$^$7$?!#e(B

% ruby -v -rsocket -e ‘p
Socket.unpack_sockaddr_un(Socket.sockaddr_in(80, “localhost”))’
ruby 1.9.0 (2006-06-04) [i686-linux]
“”
% ruby -v -rsocket -e ‘p
Socket.unpack_sockaddr_in(Socket.sockaddr_un("/tmp/s"))’
ruby 1.9.0 (2006-06-04) [i686-linux]
[12148, “localhost”]

e$B$3$l$C$F%(%i!<$N$[$&$,$$$$$s$8$c$J$$$G$7$g$&$+!#e(B

Index: ext/socket/socket.c

RCS file: /src/ruby/ext/socket/socket.c,v
retrieving revision 1.168
diff -u -p -r1.168 socket.c
— ext/socket/socket.c 4 Jun 2006 11:43:16 -0000 1.168
+++ ext/socket/socket.c 5 Jun 2006 05:15:53 -0000
@@ -3512,6 +3512,17 @@ sock_s_unpack_sockaddr_in(self, addr)
VALUE host;

 sockaddr = (struct sockaddr_in*)StringValuePtr(addr);
  • if (((struct sockaddr *)sockaddr)->sa_family != AF_INET
    +#ifdef INET6
  •    && ((struct sockaddr *)sockaddr)->sa_family != AF_INET6
    

+#endif

  •    ) {
    

+#ifdef INET6

  •    rb_raise(rb_eArgError, "not an AF_INET/AF_INET6 sockaddr");
    

+#else

  •    rb_raise(rb_eArgError, "not an AF_INET sockaddr");
    

+#endif

  • }
    host = make_ipaddr((struct sockaddr*)sockaddr);
    OBJ_INFECT(host, addr);
    return rb_assoc_new(INT2NUM(ntohs(sockaddr->sin_port)), host);
    @@ -3549,6 +3560,9 @@ sock_s_unpack_sockaddr_un(self, addr)
    VALUE path;

    sockaddr = (struct sockaddr_un*)StringValuePtr(addr);

  • if (((struct sockaddr *)sockaddr)->sa_family != AF_UNIX) {

  •    rb_raise(rb_eArgError, "not an AF_UNIX sockaddr");
    
  • }
    if (sizeof(struct sockaddr_un) < RSTRING(addr)->len) {
    rb_raise(rb_eTypeError, “too long sockaddr_un - %ld longer than %d”,
    RSTRING(addr)->len, sizeof(struct sockaddr_un));


#2

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

In message “Re: [ruby-dev:28691]
Socket.unpack_sockaddr_in(Socket.sockaddr_un(”/tmp/s")) is [12148,
“localhost”]?"
on Mon, 5 Jun 2006 14:19:30 +0900, Tanaka A. removed_email_address@domain.invalid
writes:

|e$B$U$H!“e(Bsockaddr_in e$B$re(B unpack_sockaddr_un e$B$7$?$j!“e(B
|sockaddr_un e$B$re(B unpack_sockaddr_in e$B$7$?$j$7$F$b%(%i!<$K$J$i$:e(B
|e$B$K$J$s$+CM$,JV$C$F$/$k$3$H$K5$$,$D$-$^$7$?!#e(B
|
|% ruby -v -rsocket -e ‘p Socket.unpack_sockaddr_un(Socket.sockaddr_in(80, “localhost”))’
|ruby 1.9.0 (2006-06-04) [i686-linux]
|””
|% ruby -v -rsocket -e ‘p Socket.unpack_sockaddr_in(Socket.sockaddr_un("/tmp/s"))’
|ruby 1.9.0 (2006-06-04) [i686-linux]
|[12148, “localhost”]
|
|e$B$3$l$C$F%(%i!<$N$[$&$,$$$$$s$8$c$J$$$G$7$g$&$+!#e(B

e$BF10U$7$^$9!#%3%_%C%H$7$F$/$@$5$$!#e(B