Constants
No documentation available
No documentation available
Class Methods
::
ext/socket/lib/socket.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/ext/socket/lib/socket.rb, line 977
def initialize
@addrinfo_dict = {}
@last_family = nil
end
No documentation available
Instance Methods
ext/socket/lib/socket.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/ext/socket/lib/socket.rb, line 982
def add(family_name, addrinfos)
@addrinfo_dict[family_name] = addrinfos
end
No documentation available
#
ext/socket/lib/socket.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/ext/socket/lib/socket.rb, line 1011
def any?
!empty?
end
No documentation available
#
ext/socket/lib/socket.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/ext/socket/lib/socket.rb, line 1007
def empty?
@addrinfo_dict.all? { |_, addrinfos| addrinfos.empty? }
end
No documentation available
#
ext/socket/lib/socket.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/ext/socket/lib/socket.rb, line 986
def get
return nil if empty?
if @addrinfo_dict.size == 1
@addrinfo_dict.each { |_, addrinfos| return addrinfos.shift }
end
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
end
No documentation available