From: Mathieu Bouchard Date: 2001-10-14T03:28:56+09:00 Subject: [ruby-talk:22493] Re: Socket and inetd On Sat, 13 Oct 2001, Michael Witrant wrote: > The best I could get was this: > Socket.for_fd(0).getpeername > But it returns the raw struct sockaddr. > Is there a way to obtain the peer address directly? > Else, how could I unpack the struct sockaddr to get it? class Socket def port # assumes ipv4 d=getpeername d[2]*0x100+d[3] end def addr # assumes ipv4 d=getpeername (4...8).map{|x|d[x]} end end ________________________________________________________________ Mathieu Bouchard http://hostname.2y.net/~matju