class Bundler::Settings::TCPSocketProbe

用于探测给定镜像 TCP 可用性的类。

公共实例方法

replies?(mirror) 点击以切换源代码
# File bundler/mirror.rb, line 149
def replies?(mirror)
  MirrorSockets.new(mirror).any? do |socket, address, timeout|
    socket.connect_nonblock(address)
  rescue Errno::EINPROGRESS
    wait_for_writtable_socket(socket, address, timeout)
  rescue RuntimeError # Connection failed somehow, again
    false
  end
end

私有实例方法

probe_writtable_socket(socket, address) 点击以切换源代码
# File bundler/mirror.rb, line 169
def probe_writtable_socket(socket, address)
  socket.connect_nonblock(address)
rescue Errno::EISCONN
  true
rescue StandardError # Connection failed
  false
end
wait_for_writtable_socket(socket, address, timeout) 点击以切换源代码
# File bundler/mirror.rb, line 161
def wait_for_writtable_socket(socket, address, timeout)
  if IO.select(nil, [socket], nil, timeout)
    probe_writtable_socket(socket, address)
  else # TCP Handshake timed out, or there is something dropping packets
    false
  end
end