Skip to content

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

instance method

Addrinfo#ipv4?

addrinfo.ipv4? => true or false

returns true if addrinfo is IPv4 address. returns false otherwise.

Example
Addrinfo.tcp("127.0.0.1", 80).ipv4? #=> true
Addrinfo.tcp("::1", 80).ipv4?       #=> false
Addrinfo.unix("/tmp/sock").ipv4?    #=> false