creates a newSocket connected to the address of
local_addrinfo.
If no arguments are given, the address of the socket is not bound.
If a block is given the created socket is yielded for each address.
# File ext/socket/lib/socket.rb, line 38
def connect_internal(local_addrinfo) # :yields: socket
sock = Socket.new(self.pfamily, self.socktype, self.protocol)
begin
sock.ipv6only! if self.ipv6?
sock.bind local_addrinfo if local_addrinfo
sock.connect(self)
if block_given?
yield sock
else
sock
end
ensure
sock.close if !sock.closed? && (block_given? || $!)
end
end