class Socket::HostnameResolutionStore
Constants
- PRIORITY_ON_V4
- PRIORITY_ON_V6
Public Class Methods
Source
# File ext/socket/lib/socket.rb, line 1024
def initialize(family_names)
@family_names = family_names
@addrinfo_dict = {}
@error_dict = {}
@last_family = nil
end Public Instance Methods
Source
# File ext/socket/lib/socket.rb, line 1035 def add_error(family_name, error) @addrinfo_dict[family_name] = [] @error_dict[family_name] = error end
Source
# File ext/socket/lib/socket.rb, line 1031 def add_resolved(family_name, addrinfos) @addrinfo_dict[family_name] = addrinfos end
Source
# File ext/socket/lib/socket.rb, line 1062 def any_addrinfos? !empty_addrinfos? end
Source
# File ext/socket/lib/socket.rb, line 1078 def any_unresolved_family? !resolved_all_families? end
Source
# File ext/socket/lib/socket.rb, line 1058
def empty_addrinfos?
@addrinfo_dict.all? { |_, addrinfos| addrinfos.empty? }
end Source
# File ext/socket/lib/socket.rb, line 1040
def get_addrinfo
precedences =
case @last_family
when :ipv4, nil then PRIORITY_ON_V6
when :ipv6 then PRIORITY_ON_V4
end
precedences.each do |family_name|
addrinfo = @addrinfo_dict[family_name]&.shift
next unless addrinfo
@last_family = family_name
return addrinfo
end
nil
end Source
# File ext/socket/lib/socket.rb, line 1066 def resolved?(family) @addrinfo_dict.has_key? family end
Source
# File ext/socket/lib/socket.rb, line 1074 def resolved_all_families? (@family_names - @addrinfo_dict.keys).empty? end
Source
# File ext/socket/lib/socket.rb, line 1070 def resolved_successfully?(family) resolved?(family) && !!@error_dict[family] end
Ruby Core © 1993–2024 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.