This adds a secondary check to see if the OS actually supports IPv6 sockets

git-svn-id: file:///home/svn/framework3/trunk@4815 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2007-04-30 00:11:49 +00:00
parent 83a8ece022
commit abb0ac92d9
1 changed files with 20 additions and 1 deletions

View File

@ -77,11 +77,30 @@ module Socket
#
##
# Cache our IPv6 support flag
@@support_ipv6 = nil
#
# Determine whether we support IPv6
#
def self.support_ipv6?
::Socket.const_defined?('AF_INET6') ? true : false
if(@@support_ipv6)
return (@@support_ipv6 == "yes" ? true : false)
end
@@support_ipv6 = "no"
if (::Socket.const_defined?('AF_INET6'))
begin
s = ::Socket.new(::Socket::AF_INET6, ::Socket::SOCK_DGRAM, ::Socket::IPPROTO_UDP)
s.close
@@support_ipv6 = "yes"
rescue ::SocketError
end
end
return (@@support_ipv6 == "yes" ? true : false)
end
#