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)
ext/socket/lib/socket.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/ext/socket/lib/socket.rb, line 230
def self.foreach(nodename, service, family=nil, socktype=nil, protocol=nil, flags=nil, timeout: nil, &block)
Addrinfo.getaddrinfo(nodename, service, family, socktype, protocol, flags, timeout: timeout).each(&block)
end
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)>