def connect(self, ssl=None, timeout=None):
<EOL>connections = sorted(self.connections, key=lambda c: c.local, reverse=True)<EOL>owned_or_unowned_non_local = lambda x: self.owned or (not self.owned and not x.local)<EOL>https = [c.uri for c in connections if owned_or_unowned_non_local(c)]<EOL>http = [c.httpuri for c in connections if owned_or_unowned_non_local(c)]<EOL>cls = PlexServer if '<STR_LIT>' in self.provides else PlexClient<EOL>if ssl is True: connections = https<EOL>elif ssl is False: connections = http<EOL>else: connections = https + http<EOL>listargs = [[cls, url, self.accessToken, timeout] for url in connections]<EOL>log.info('<STR_LIT>', len(listargs))<EOL>results = utils.threaded(_connect, listargs)<EOL>return _chooseConnection('<STR_LIT>', self.name, results)<EOL>
Returns a new :class:`~server.PlexServer` or :class:`~client.PlexClient` object.
            Often times there is more than one address specified for a server or client.
            This function will prioritize local connections before remote and HTTPS before HTTP.
            After trying to connect to all available addresses for this resource and
            assuming at least one connection was successful, the PlexServer object is built and returned.

            Parameters:
                ssl (optional): Set True to only connect to HTTPS connections. Set False to
                    only connect to HTTP connections. Set None (default) to connect to any
                    HTTP or HTTPS connection.

            Raises:
                :class:`plexapi.exceptions.NotFound`: When unable to connect to any addresses for this resource.