def cli():
    s = snakemq.link.Link()

    def on_connect(conn_id):
        check_barrier()
        for i in xrange(PACKETS_COUNT):
            tr.send_packet(conn_id, "x" * DATA_SIZE)

    def on_disconnect(conn_id):
        s.stop()

    # listen queue on the server is short so the reconnect interval needs to be
    # short because all clients are trying to connect almost at the same time
    s.add_connector(("localhost", PORT), reconnect_interval=0.3)
    # spread the connections
    time.sleep(random.randint(0, 1000) / 1000.0)

    tr = snakemq.packeter.Packeter(s)
    tr.on_connect = on_connect
    tr.on_disconnect = on_disconnect
    s.loop()
    s.cleanup()