Skip to content
class method

Addrinfo.foreach

(::String? nodename, ::String | ::Integer service, ?::Integer? family, ?::Symbol socktype, ?::Symbol | ::Integer protocol, ?::Integer flags, ?timeout: ::Numeric) { (::Addrinfo) -> void } -> void
(::String? nodename, ::String | ::Integer service, ?::Integer? family, ?::Symbol socktype, ?::Symbol | ::Integer protocol, ?::Integer flags, ?timeout: ::Numeric) -> ::Enumerable[::Addrinfo]
foreach(nodename, service, family=nil, socktype=nil, protocol=nil, flags=nil, timeout: nil, &block)

iterates over the list of Addrinfo objects obtained by Addrinfo.getaddrinfo.

Example
Addrinfo.foreach(nil, 80) {|x| p x }
#=> #<Addrinfo: 127.0.0.1:80 TCP (:80)>
#   #<Addrinfo: 127.0.0.1:80 UDP (:80)>
#   #<Addrinfo: [::1]:80 TCP (:80)>
#   #<Addrinfo: [::1]:80 UDP (:80)>
See also .getaddrinfo .ip also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0