Class: Bundler::MirrorSockets
- Inherits:
-
Object
- Object
- Bundler::MirrorSockets
- Defined in:
- lib/bundler/mirror.rb
Overview
Class used to build the list of sockets that correspond to
a given mirror.
One mirror may correspond to many different addresses, both
because of it having many dns entries or just because
the network interface is both ipv4 and ipv5
Instance Method Summary collapse
- #any? ⇒ Boolean
-
#initialize(mirror) ⇒ MirrorSockets
constructor
A new instance of MirrorSockets.
Constructor Details
#initialize(mirror) ⇒ MirrorSockets
Returns a new instance of MirrorSockets.
183 184 185 186 187 188 |
# File 'lib/bundler/mirror.rb', line 183 def initialize(mirror) @timeout = mirror.fallback_timeout @addresses = Socket.getaddrinfo(mirror.uri.host, mirror.uri.port).map do |address| SocketAddress.new(address[0], address[3], address[1]) end end |
Instance Method Details
#any? ⇒ Boolean
190 191 192 193 194 195 196 197 198 |
# File 'lib/bundler/mirror.rb', line 190 def any? @addresses.any? do |address| socket = Socket.new(Socket.const_get(address.type), Socket::SOCK_STREAM, 0) socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) value = yield socket, address.to_socket_address, @timeout socket.close unless socket.closed? value end end |