1. CoreExtensions::
  2. TCPSocketExt::
  3. Initializer

module CoreExtensions::TCPSocketExt::Initializer

Constants

CONNECTION_TIMEOUT
IPV4_DELAY_SECONDS

Public Class Methods

Source
# File lib/rubygems/core_ext/tcpsocket_init.rb, line 15definitialize(host,serv,*rest)mutex =Thread::Mutex.newaddrs = []threads = []cond_var =Thread::ConditionVariable.newAddrinfo.foreach(host,serv,nil,:STREAM)do|addr|Thread.report_on_exception =falsethreads<<Thread.new(addr)do# give head start to ipv6 addressessleepIPV4_DELAY_SECONDSifaddr.ipv4?# raises Errno::ECONNREFUSED when ip:port is unreachableSocket.tcp(addr.ip_address,serv,connect_timeout:CONNECTION_TIMEOUT).closemutex.synchronizedoaddrs<<addr.ip_addresscond_var.signalendendendmutex.synchronizedotimeout_time =CONNECTION_TIMEOUT+Time.now.to_fwhileaddrs.empty?&& (remaining_time =timeout_time-Time.now.to_f)>0cond_var.wait(mutex,remaining_time)endhost =addrs.shiftunlessaddrs.empty?endthreads.each {|t|t.kill.joinift.alive? }super(host,serv,*rest)end
Calls superclass method