Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

UNIXSocket#peeraddr

unixsocket.peeraddr => [address_family, unix_path]

Returns the remote address as an array which contains address_family and unix_path.

Example

Example
serv = UNIXServer.new("/tmp/sock")
c = UNIXSocket.new("/tmp/sock")
p c.peeraddr #=> ["AF_UNIX", "/tmp/sock"]
See also #path #recvfrom #addr #recv_io also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1