ipv4?

addrinfo.ipv4? => true or false Instance Public methods returns true if addrinfo is IPv4 address. returns false otherwise. Addrinfo.tcp("127.0.0.1", 80).ipv4? #=> true Addrinfo.tcp("::1", 80).ipv4? #=> false Addrinfo.unix("/tmp/sock").ipv4? #=> false

ip_unpack

addrinfo.ip_unpack => [addr, port] Instance Public methods Returns the IP address and port number as 2-element array. Addrinfo.tcp("127.0.0.1", 80).ip_unpack #=> ["127.0.0.1", 80] Addrinfo.tcp("::1", 80).ip_unpack #=> ["::1", 80]

ip_port

addrinfo.ip_port => port Instance Public methods Returns the port number as an integer. Addrinfo.tcp("127.0.0.1", 80).ip_port #=> 80 Addrinfo.tcp("::1", 80).ip_port #=> 80

ip_address

addrinfo.ip_address => string Instance Public methods Returns the IP address as a string. Addrinfo.tcp("127.0.0.1", 80).ip_address #=> "127.0.0.1" Addrinfo.tcp("::1", 80).ip_address #=> "::1"

ip?

addrinfo.ip? => true or false Instance Public methods returns true if addrinfo is internet (IPv4/IPv6) address. returns false otherwise. Addrinfo.tcp("127.0.0.1", 80).ip? #=> true Addrinfo.tcp("::1", 80).ip? #=> true Addrinfo.unix("/tmp/sock").ip? #=> false

inspect_sockaddr

addrinfo.inspect_sockaddr => string Instance Public methods returns a string which shows the sockaddr in addrinfo with human-readable form. Addrinfo.tcp("localhost", 80).inspect_sockaddr #=> "127.0.0.1:80" Addrinfo.tcp("ip6-localhost", 80).inspect_sockaddr #=> "[::1]:80" Addrinfo.unix("/tmp/sock").inspect_sockaddr #=> "/tmp/sock"

inspect

addrinfo.inspect => string Instance Public methods returns a string which shows addrinfo in human-readable form. Addrinfo.tcp("localhost", 80).inspect #=> "#<Addrinfo: 127.0.0.1:80 TCP (localhost)>" Addrinfo.unix("/tmp/sock").inspect #=> "#<Addrinfo: /tmp/sock SOCK_STREAM>"

getnameinfo

addrinfo.getnameinfo => [nodename, service]addrinfo.getnameinfo(flags) => [nodename, service] Instance Public methods returns nodename and service as a pair of strings. This converts struct sockaddr in addrinfo to textual representation. flags should be bitwise OR of Socket::NI_??? constants. Addrinfo.tcp("127.0.0.1", 80).getnameinfo #=> ["localhost", "www"] Addrinfo.tcp("127.0.0.1", 80).getnameinfo(Socket::NI_NUMERICSERV) #=> ["localhost", "80"]

family_addrinfo

family_addrinfo(*args) Instance Public methods creates an Addrinfo object from the arguments. The arguments are interpreted as similar to self. Addrinfo.tcp("0.0.0.0", 4649).family_addrinfo("www.ruby-lang.org", 80) #=> #<Addrinfo: 221.186.184.68:80 TCP (www.ruby-lang.org:80)> Addrinfo.unix("/tmp/sock").family_addrinfo("/tmp/sock2") #=> #<Addrinfo: /tmp/sock2 SOCK_STREAM>

connect_to

addrinfo.connect_to([remote_addr_args], [opts]) {|socket| ... }addrinfo.connect_to([remote_addr_args], [opts]) Instance Public methods creates a socket connected to remote_addr_args and bound to self. The optional last argument opts is options represented by a hash. opts may have following options: :timeout specify the timeout in seconds. If a block is given, it is called with the socket and the value of the block is returned. The socket is returned otherwise. Addrinfo.tcp("0