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