5 /* Ecore_Con client example
6 * 2010 Mike Blumenkrantz
9 #define NUM_CLIENTS 30000
11 static Eina_Counter *counter;
16 _add(void *data, int type, Ecore_Con_Event_Server_Add *ev)
19 printf("Connection #%i!\n", add);
20 if (add == NUM_CLIENTS)
21 ecore_main_loop_quit();
23 return ECORE_CALLBACK_RENEW;
27 _del(void *data, int type, Ecore_Con_Event_Server_Add *ev)
30 printf("Connection lost! #%i!\n", del);
32 return ECORE_CALLBACK_RENEW;
40 for (x = 0; x < NUM_CLIENTS; x++)
42 // printf("Creating connection %i\n", x);
43 if (!ecore_con_server_connect(ECORE_CON_REMOTE_NODELAY, "127.0.0.1", 8080, NULL))
45 printf("CRITICAL ERROR!\n"
46 "Could not create connection #%i!\n", x);
50 printf("***Job done***\n");
61 eina_log_domain_level_set("ecore_con", EINA_LOG_LEVEL_ERR);
62 eina_log_domain_level_set("eina", EINA_LOG_LEVEL_ERR);
63 counter = eina_counter_new("client");
64 eina_counter_start(counter);
65 done = ecore_time_get();
67 ecore_job_add(_spawn, NULL);
69 /* set event handler for server connect */
70 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb)_add, NULL);
71 ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb)_del, NULL);
74 ecore_main_loop_begin();
75 eina_counter_stop(counter, 1);
76 printf("\nTime elapsed for %i connections: %f seconds\n%s", NUM_CLIENTS, ecore_time_get() - done, eina_counter_dump(counter));