getnameinfo

Socket.getnameinfo(sockaddr [, flags]) => [hostname, servicename]
Class Public methods

Obtains name information for sockaddr.

sockaddr should be one of follows.

  • packed sockaddr string such as ::sockaddr_in(80, â127.0.0.1â)

  • 3-elements array such as [âAF_INETâ, 80, â127.0.0.1â]

  • 4-elements array such as [âAF_INETâ, 80, ignored, â127.0.0.1â]

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, "127.0.0.1"))       #=> ["localhost", "www"]
Socket.getnameinfo(["AF_INET", 80, "127.0.0.1"])              #=> ["localhost", "www"]
Socket.getnameinfo(["AF_INET", 80, "localhost", "127.0.0.1"]) #=> ["localhost", "www"]

If Addrinfo object is preferred, use Addrinfo#getnameinfo.

doc_ruby_on_rails
2015-05-15 05:27:38
Comments
Leave a Comment

Please login to continue.