Exemple #1
0
int main(void)
{
    tls_client_t client = {0};
    const char *gnutls_ver = NULL;
    time_t start = 0;
    time_t end = 0;
    int ret = 0;
    int i = 0;

    /* initialise signal handling */
    set_signal();

    coap_log_set_level(COAP_LOG_DEBUG);

    gnutls_ver = gnutls_check_version(NULL);
    if (gnutls_ver == NULL)
    {
        coap_log_error("Unable to determine GnuTLS version");
        return EXIT_FAILURE;
    }
    coap_log_info("GnuTLS version: %s", gnutls_ver);

    ret = tls_init();
    if (ret != SOCK_OK)
    {
        coap_log_error("%s", sock_strerror(ret));
        return EXIT_FAILURE;
    }

    ret = tls_client_create(&client, TRUST_FILE_NAME, CERT_FILE_NAME, KEY_FILE_NAME);
    if (ret != SOCK_OK)
    {
        coap_log_error("%s", sock_strerror(ret));
        tls_deinit();
        return EXIT_FAILURE;
    }

    for (i = 0; i < NUM_ITER; i++)
    {
        start = time(NULL);
        ret = client_run(&client);
        end = time(NULL);
        if (ret != SOCK_OK)
        {
            coap_log_error("%s", sock_strerror(ret));
            tls_client_destroy(&client);
            tls_deinit();
            return EXIT_FAILURE;
        }
        coap_log_info("Result: %s", sock_strerror(ret));
        coap_log_debug("Time: %d sec", (int)(end - start));
        coap_log_debug("Sleeping for %d seconds...", DELAY);
        sleep(DELAY);
    }

    tls_client_destroy(&client);
    tls_deinit();
    return EXIT_SUCCESS;
}
Exemple #2
0
		*/
	}
}

END:
	tls_client_stop(client_tls_ctx, client, var_client_starttls_tmout, 0, client_sess_ctx);
	acl_vstream_close(client);
}

static void *run_thread(void *arg acl_unused)
{
	int   i, n = 1000000;
	time_t last = time(NULL), now;
	TLS_APPL_STATE *client_tls_ctx;

	client_tls_ctx = tls_client_create(&init_props);
	if (client_tls_ctx == NULL) {
		printf("tls_client_create error\n");
		return (NULL);
	}

	for (i = 0; i < n; i++) {
		run_one(client_tls_ctx);
		if (i % 100 == 0) {
			now = time(NULL);
			printf("i: %d, time: %ld\n", i, now - last);
			last = now;
		}
	}

	tls_free_app_context(client_tls_ctx);