# File lib/mongo/util/uri_parser.rb, line 143
    def connection(extra_opts, legacy = false, sharded = false)
      opts = connection_options.merge!(extra_opts)
      if(legacy)
        if replicaset?
          ReplSetConnection.new(node_strings, opts)
        else
          Connection.new(host, port, opts)
        end
      else
        if sharded
          MongoShardedClient.new(node_strings, opts)
        elsif replicaset?
          MongoReplicaSetClient.new(node_strings, opts)
        else
          MongoClient.new(host, port, opts)
        end
      end
    end