Ejemplo n.º 1
0
int main(const int argc, const char **argv)
{
	int minTime, resolve;

	g_ape = native_netlib_init();
	g_ape->is_running = ape_running = 1;

	resolve = 0;
	if (argc == 1) {
		minTime = MIN_TIMEOUT;
	} else if (argc == 2) {
		minTime = atoi(argv[1]);
	} else if (argc == 3) {
		minTime = atoi(argv[1]);
		resolve = 1;
	} else {
		printf("Usage: %s [timeout] [resolve]\n\tdefault timeout: %d\n\tactivate dns socket: %d", argv[0], MIN_TIMEOUT, resolve);
		exit(1);
	}
	printf("starting interval with %d with%s resolving\n", minTime, (resolve)?"":"out");
	ape_gethostbyname("nidium.com", resolve_cb, NULL, g_ape);
	if (resolve){
		add_timer(&g_ape->timersng, minTime, interval_cb, &minTime);
	}
	
	events_loop(g_ape);
	native_netlib_destroy(g_ape);

	return 0;
}
Ejemplo n.º 2
0
void ape_connect_name(char *name, int port, ape_socket *pattern, acetables *g_ape)
{
	struct _ape_sock_connect_async *asca = xmalloc(sizeof(*asca));
	
	asca->sock = pattern;
	asca->port = port;

	ape_gethostbyname(name, ape_connect_name_cb, asca, g_ape);
}
Ejemplo n.º 3
0
TEST(DNS, Resolve)
{
    ape_global *g_ape;
    ape_dns_state *dns_state;

    g_ape = APE_init();

    ape_running = g_ape->is_running = 1;
    dns_state = ape_gethostbyname("nidium.com", shutdown_loop_on_resolve,
                                  (void *)"195.154.184.149", g_ape);
    APE_loop_run(g_ape);

    ape_running = g_ape->is_running = 1;
    dns_state = ape_gethostbyname("212.83.162.183", shutdown_loop_on_resolve,
                                  (void *)"212.83.162.183", g_ape);
    APE_loop_run(g_ape);

    APE_destroy(g_ape);
}