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

Addrinfo#ip_port

addrinfo.ip_port => port

Returns the port number as an integer.

Example
Addrinfo.tcp("127.0.0.1", 80).ip_port    #=> 80
Addrinfo.tcp("::1", 80).ip_port          #=> 80
See also #ip_address #ip_unpack #ip? #ipv4? also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1