def construct_conn_msg(stream, lines=None, protocol_opts=None):
    """Return a connnection message

    :param stream: stream name
    :param lines: number of messages to consume
    :param protocol_opts: optional arguments
    """
    connection_msg = stream
    if lines:
        connection_msg += ' {0}'.format(lines)
    if protocol_opts:
        connection_msg += ''.join([' {0}={1}'.format(k, v) for k, v in protocol_opts.items()])
    return connection_msg + '\n'