def connect_forwarder(forward_host=None,<EOL>forward_port=None,<EOL>max_retries=-<NUM_LIT:1>,<EOL>sleep_interval=<NUM_LIT:1.0>):
forward_skt = None<EOL>retry_count = <NUM_LIT:0><EOL>if max_retries == -<NUM_LIT:1>:<EOL><INDENT>retry_count = -<NUM_LIT:2><EOL><DEDENT>if forward_host and forward_port:<EOL><INDENT>while not forward_skt andretry_count < max_retries:<EOL><INDENT>try:<EOL><INDENT>forward_skt = socket.socket()<EOL>log.info(("<STR_LIT>")<EOL>.format(forward_host,<EOL>forward_port))<EOL>forward_skt.connect((forward_host,<EOL>forward_port))<EOL>log.debug(("<STR_LIT>")<EOL>.format(forward_host,<EOL>forward_port))<EOL><DEDENT>except Exception as s:<EOL><INDENT>forward_skt = None<EOL>log.error(("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>.format(forward_host,<EOL>forward_port,<EOL>s))<EOL>if max_retries == -<NUM_LIT:1>:<EOL><INDENT>retry_count = -<NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>retry_count += <NUM_LIT:1><EOL><DEDENT><DEDENT>time.sleep(sleep_interval)<EOL><DEDENT><DEDENT>return forward_skt<EOL>
connect_forwarder

    :param forward_host: host for receiving forwarded packets
    :param forward_port: port for the forwarded packets
    :param max_retries: retries, -1 = infinite
    :param sleep_interval: how often to retry in this loop