<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def connect_proxy(self, proxy_host='localhost', proxy_port=0, proxy_type=socks.HTTP, host='localhost', port=0):
 """Connect to a host on a given port via proxy server If the hostname ends with a colon (`:') followed by a number, and there is no port specified, that suffix will be stripped off and the number interpreted as the port number to use. Note: This method is automatically invoked by __init__, if a host and proxy server are specified during instantiation. :param proxy_host: Hostname of proxy server :type proxy_host: string :param proxy_port: Port of proxy server, by default port for specified proxy type is used :type proxy_port: int :param proxy_type: Proxy type to use (see socks.PROXY_TYPES for details) :type proxy_type: int :param host: Hostname of SMTP server :type host: string :param port: Port of SMTP server, by default smtplib.SMTP_PORT is used :type port: int :return: Tuple of (code, msg) :rtype: tuple """

        if proxy_type not in socks.DEFAULT_PORTS.keys():
            raise NotSupportedProxyType
        (proxy_host, proxy_port) = self._parse_host(host=proxy_host, port=proxy_port)
        if not proxy_port:
            proxy_port = socks.DEFAULT_PORTS[proxy_type]
        (host, port) = self._parse_host(host=host, port=port)
        if self.debuglevel > 0:
            self._print_debug('connect: via proxy', proxy_host, proxy_port)
        s = socks.socksocket()
        s.set_proxy(proxy_type=proxy_type, addr=proxy_host, port=proxy_port)
        s.settimeout(self.timeout)
        if self.source_address is not None:
            s.bind(self.source_address)
        s.connect((host, port))
        # todo
        # Send CRLF in order to get first response from destination server.
        # Probably it's needed only for HTTP proxies. Further investigation required.
        s.sendall(bCRLF)
        self.sock = s
        (code, msg) = self.getreply()
        if self.debuglevel > 0:
            self._print_debug('connect:', repr(msg))
        return code, msg