'Connect to the current SAMP Hub.
Parameters
hub : `~astropy.samp.SAMPHubServer`, optional
The hub to connect to.
hub_params : dict, optional
Optional dictionary containing the lock-file content of the Hub
with which to connect. This dictionary has the form
``{<token-name>: <token-string>, ...}``.
pool_size : int, optional
The number of socket connections opened to communicate with the
Hub.'

def connect(self, hub=None, hub_params=None, pool_size=20):

    self._connected = False
    self.lockfile = {}
    if ((hub is not None) and (hub_params is not None)):
        raise ValueError(u'Cannot    specify    both    hub    and    hub_params')
    if (hub_params is None):
        if (hub is not None):
            if (not hub.is_running):
                raise SAMPHubError(u'Hub    is    not    running')
            else:
                hub_params = hub.params
        else:
            hub_params = get_main_running_hub()
    try:
        url = hub_params[u'samp.hub.xmlrpc.url'].replace(u'\\', u'')
        self.proxy = ServerProxyPool(pool_size, xmlrpc.ServerProxy, url, allow_none=1)
        self.ping()
        self.lockfile = copy.deepcopy(hub_params)
        self._connected = True
    except xmlrpc.ProtocolError as p:
        if (p.errcode == 401):
            raise SAMPHubError(u'Unauthorized    access.    Basic    Authentication    required    or    failed.')
        else:
            raise SAMPHubError(u'Protocol    Error    {}:    {}'.format(p.errcode, p.errmsg))
