<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def outgoing(cls, hostport, process_name=None, serve_hostport=None, handler=None, tchannel=None):
 """Initiate a new connection to the given host. :param hostport: String in the form ``$host:$port`` specifying the target host :param process_name: Process name of the entity making the connection. :param serve_hostport: String in the form ``$host:$port`` specifying an address at which the caller can be reached. If omitted, ``0.0.0.0:0`` is used. :param handler: If given, any calls received from this connection will be sent to this RequestHandler. """

        host, port = hostport.rsplit(":", 1)
        process_name = process_name or "%s[%s]" % (sys.argv[0], os.getpid())
        serve_hostport = serve_hostport or "0.0.0.0:0"

        # TODO: change this to tornado.tcpclient.TCPClient to do async DNS
        # lookups.
        stream = tornado.iostream.IOStream(
            socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        )

        log.debug("Connecting to %s", hostport)
        try:
            yield stream.connect((host, int(port)))

            connection = cls(stream, tchannel, direction=OUTGOING)

            log.debug("Performing handshake with %s", hostport)

            yield connection.initiate_handshake(headers={
                'host_port': serve_hostport,
                'process_name': process_name,
                'tchannel_language': TCHANNEL_LANGUAGE,
                'tchannel_language_version': TCHANNEL_LANGUAGE_VERSION,
                'tchannel_version': TCHANNEL_VERSION,
            })
        except (StreamClosedError, socket.error, errors.TimeoutError) as e:
            log.warn("Couldn't connect to %s", hostport)
            raise NetworkError(
                "Couldn't connect to %s" % hostport, e
            )

        if handler:
            connection.serve(handler)

        raise tornado.gen.Return(connection)