getnameinfo(p1, p2 = v2) public

Obtains name information for sockaddr.

sockaddr should be one of follows.

  • packed sockaddr string such as Socket.sockaddr_in(80, “”)

  • 3-elements array such as [“AF_INET”, 80, “”]

  • 4-elements array such as [“AF_INET”, 80, ignored, “”]

flags should be bitwise OR of Socket::NI_* constants.

Note: The last form is compatible with IPSocket#addr and IPSocket#peeraddr.

Socket.getnameinfo(Socket.sockaddr_in(80, ""))       #=> ["localhost", "www"]
Socket.getnameinfo(["AF_INET", 80, ""])              #=> ["localhost", "www"]
Socket.getnameinfo(["AF_INET", 80, "localhost", ""]) #=> ["localhost", "www"]

If Addrinfo object is preferred, use Addrinfo#getnameinfo.

Show source
Register or log in to add new notes.